Rajesh Naroth
1 min readJul 2, 2019

--

The only problem I had with Redux was the mapStateToProps, mapDispatchToProps and connect() boilerplate. This filled the component code base with awful looking Container components that were really tough to read. HOCs do not express its intentions well.

However, with new hooks support, Containers read quite well.

const count = useSelector(state => state.count)
const dispatch = useDispatch();
const incrementCounter = () => dispatch({
type: 'increment-counter'
});
return <Counter count={count} incrementCounter={incrementCounter}/>

Reads so much better!

Attempts to replace Redux with useReducer() and useContext() hooks will all end up rewriting Redux all over again. Nothing gained. Trust me. I’ve tried it.

--

--

Rajesh Naroth
Rajesh Naroth

Written by Rajesh Naroth

Frontend Architect, San Jose, CA

No responses yet