Does anyone know of a React & Redux tutorial that doesn't depend on ES6/2015?
It's difficult to attempt to learn a complex idea like Redux, let alone search for 'redux react tutorial without ES6' on Google. Please don't say 'just learn ES6...' Yes, I know.
Thank you!
Redux is not a complicated idea. It can be expressed in very few lines of code:
function createStore(reducer, state) {
var listeners = [];
var currentState = state;
function subscribe(listener) {
listeners.push(listener);
return function unsubscribe() {
listeners = listeners.splice(listeners.indexOf(listener), 1);
};
}
function getState() {
return state;
}
function dispatch(action) {
currentState = reducer(currentState, action);
for (var i = 0; i < listeners.length; ++i) {
listeners[i]();
}
}
return {
getState: getState,
subscribe: subscribe,
dispatch: dispatch
};
}
That's the basic idea. Of course, the actual library has a ton of sanity checks and additional validation, and adds extra things like middleware and store enhancers and such, but the core is as above.
What you really want is a basic React tutorial without all the extra stuff, and for that I would highly recommend James Knelson's excellent tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With