React Hooks Vs React-redux

Viewed 3760

After introducing hooks to Reactjs, Are they a good replacement for global store management like Redux or not? It's about their performance to react.

I have used Redux and redux-saga in my recent projects but after introducing hooks I'm interested to replace them.

1 Answers

One thing you need to understand is that hooks aren't meant to replace redux stores nor are they used for global store management. You use hooks so as to make the implementation of the components easier(replacing class components with functional components ), the components will themselves still rely on some data that is stored in the redux store. You use redux so that multiple components in your app can use the same redux store.

For example, say you have 2 components a <Hello> that says "Hello user_name" and a <Welcome> that says "Welcome user_name". Now both these components require the same data which is user_name. If we use a redux store we can store the data in a single location and use it throughout the app by passing it as a prop. Now we can implement the <Welcome> and the <Hello> with hooks instead of class components but the data that they need should come from a global store.

Related