DEV Community

Cover image for Does React Hooks Replace Redux: Where to use Which?
Kat Holder
Kat Holder

Posted on • Updated on

Does React Hooks Replace Redux: Where to use Which?

Redux vs React Hooks is a pretty much old debate. Which one to go for and which may be replaced by what. Let's find out.

What is Redux?

Redux is a predictable state management library and architecture which easily integrates with React.
The primary selling points of Redux are:

  • Deterministic state resolution (enabling deterministic view renders when combined with pure components).
  • Transactional state.
  • Isolate state management from I/O and side effects.
  • Single source of truth for application state.
  • Easily share state between different components.
  • Transaction telemetry (auto-logging action objects).
  • Time travel debugging.

To put it another way, Redux provides you with superpowers in terms of code structure and debugging. It's easier to write more maintainable code, and it's a lot easier to figure out what's wrong when anything goes wrong.

What is React?

React hooks let you use state and React lifecycle features without using class and React component lifecycle methods. They were introduced in React 16.8.
The primary selling points of React hooks are:

  • Use state and hook into the component lifecycle without using a class.
  • Colocate related logic in one place in your component, rather than splitting it between various lifecycle methods.
  • Share reusable behaviors independent of component implementations.
  • It's worth noting that these wonderful benefits don't actually overlap with Redux's. To obtain consistent state updates, you should indeed utilize React hooks, but that has always been a part of React, and Redux's deterministic state model fits right in. That's how React allows for deterministic view rendering, and it's one of the main reasons for the framework's inception.

Top comments (0)