I'm trying to integrate simpreWebRTC to my React-Redux project, but the library has their own redux store and the documentation says this:
"The provided createStore
function makes a basic Redux
store useful for getting things started. If you want to
make your own, import reducer
from '@andyet/simplewebrtc' and
be sure to assign it to simplewebrtc
in the top level of
your state object."
I've tried several approaches but nothing works, any idea? what I'm missing here? Thanks
This is the code that I have so far:
store.js
import {createStore, applyMiddleware} from 'redux'
import rootReducer from './reducers/index'
import thunk from 'redux-thunk';
export default createStore(rootReducer, applyMiddleware(thunk));
const store = createStore(rootReducer);
console.log(store.getState());
./reducers/index.js
import {combineReducers} from 'redux'
import {reducer as simplewertc} from '@andyet/simplewebrtc'
import liveRoomReducer from './liveRoomReducer'
export default combineReducers({simplewertc, liveRoomReducer});
./reducers/liveRoomReducer.js
const initialState = {
test : 'test'
};
export default function liveRoomReducer(state=initialState, action) {
return state;
};
I'm logging the store state in the console and is showing simplewebrtc on it:
And still showing this error:
Creating your own store with thunk middleware and using combineReducers
should do the trick:
import {combineReducers} from 'redux';
import {reducer as simplewebrtc} from '@andyet/simplewebrtc';
import reducer1 from 'path/to/your/reducer1';
import reducer2 from 'path/to/your/reducer2';
export default combineReducers({simplewebrtc, reducer1 , reducer2});
If that isn't working for you please provide what error is showing up if any and some example code of how you create your redux store and root reducer.
Edit: After seeing the updated question with code, we found the problem was in a typo when importing the reducer.