-
Notifications
You must be signed in to change notification settings - Fork 101
Closed
Description
Internally the module uses ImmutalbleJS for setting the api-states, but the api-reducer cannot be combined with existing reducers when the initialState of the store is Immutable:
For example:
const redux = require('redux');
const Immutable = require('immutable');
const redux_immutable = require('redux-immutable');
const redux_thunk = require('redux-thunk').default;
const redux_json_api = require('redux-json-api');
const api = redux_json_api.reducer;
const reducers = redux_immutable.combineReducers({api});
const initialState = Immutable.Map();
const middlewares = redux.applyMiddleware(redux_thunk);
const store = redux.createStore(reducers, initialState, middlewares );
store.subscribe(() => console.log(store.getState().toJS()) )
store.dispatch(redux_json_api.setEndpointHost('http://ip.jsontest.com/'));
store.dispatch(redux_json_api.setAccessToken('access_token_123123'));
store.dispatch(redux_json_api.readEndpoint('/'))
This code results in:
TypeError: Cannot read property 'endpoint' of undefined: getState().api.endpoint;
The code looks like:
const { host: apiHost, path: apiPath, headers } = getState().api.endpoint;
I think (in case the root-state is Immutable) this should be something like:
const { host: apiHost, path: apiPath, headers } = getState().get('api').endpoint;
Metadata
Metadata
Assignees
Labels
No labels