Languages

What is better to mange components state, Context API or REDUX?

8 points
Asked by:
Saim-Mccullough
388

I heard many things about writing React applications with Redux or without (props + contexts).

People advise to do not use Redux if the application is small.

When I was checking Facebook with the React DevTools inspector, I have noticed that they use a lot of Providers inside.

What has better performance? And what I should use?

1 answer
3 points
Answered by:
Saim-Mccullough
388

Redux uses Context API inside to share state across components.

But Redux does it in a smarter way.

Contexts accessing in child components to read some value is fast, context value modifications are slow. So Redux creates some context hooks inside components just to have access to them (context value reading only) and forces components rerendering and data updates in its own way.

Using Redux we are sure the rerendering occurs only in child components that need it.

If you know how to use Context API in a smart way, or your application is really small, you can use contexts.

Hint: consider using memo() too, to force rerendering only components that hook contexts.

See also

  1. How to use React Context effectively
0 comments Add comment
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join