4 ms·
Not counting other parts of its API like combineReducers and subscribing listeners, Redux is essentially.. function createStore(reducer, initialState) {
by honua 11y ago
Not counting other parts of its API like combineReducers and subscribing listeners, Redux is essentially..
function createStore(reducer, initialState) {
let state = initialState;
return {
dispatch(action) {
state = reducer(state, action);
},
getState() {
return state;
}
}
}
It's quite simple.. and yes, it should only be used when needed, but the whole implementation of the Redux part of an app can exist in a few lines in a single file.