I learned how to Redux with Teropa's incredible tutorial. However, his implementation uses Immutable and, while awesome, is something I want to remove from my current app's build. I'm trying to figure out how to maintain the following without relying on Immutable. I somehow need to modify reducer.js to take out Immutable, but the exported function keeps failing without state = Map().
Index.jsx
store.dispatch({
type: 'SET_STATE',
state: { ... }
});
action_creators.js
export function setState(state) {
return {
type: 'SET_STATE',
state
};
}
reducer.js
import { Map } from 'immutable';
function setState(state, newState) {
return state.merge(newState);
}
export default function(state = Map(), action) {
switch (action.type) {
case 'SET_STATE':
return setState(state, action.state);
}
return state;
}
Mapwith a standard JavaScript object and useObject.assignto merge things into it. I'd recommend reading the Reducers chapter in the official Redux tutorial - it takes you through this step by step.