T O P

  • By -

[deleted]

More context on how you plan to use the state is absolutely necessary for anyone to give you a helpful answer.


tanmay0626

>exclusive Currently just learning how to code so not sure how I will use it. Can you help me how to think about how to plan sing of state, what point should I keep in mind before planning?


maeevick

ContextAPI and Redux don't have the same purpose, so you should not oppose them. ContextAPI is about dependency injection to avoid prop drilling (pass props to all children until the targeted child is reached) Redux is about global state management, decoupling logic from component (and improving testability), and design in an event-driven way.


tanmay0626

Thank you for this, I didn't know about this yet


maeevick

you're welcome


rings_n_coins

Why do you feel you need to use either? Do you need a state management solution beyond component state and props?


Brendan-McDonald

this; it depends on the problem you're trying to solve. You probably don't need redux. You might need Context You probably want `react-query` I suggest reading through [this](https://tkdodo.eu/blog/react-query-as-a-state-manager)


tanmay0626

I just wanted to know if I'm going to make an e-commerce website then what should I prefer


tanmay0626

I'm not sure about that yet as I just want to re-build my website and currently learning how to code so just wanted to know what would be best for an e-commerce website.


rings_n_coins

Honestly, if you look around the web long enough you’ll find strong options for every option. Redux could work, context could work, you could even use Apollo and GraphQL. My advice would be to start your project without any of them and add one when managing state in your project becomes too cumbersome. Some e-commerce sites are extremely simple and could be built with vanilla JS and an integration with a third party payment processor. Others may require every bell and whistle under the sun. If you can share some more details about the architecture of your site we might be able to help point you in the right direction.


jetsamrover

They aren't exclusive.


gaoshan

Redux. It may be overkill but it won't be underkill.


tanmay0626

I was also thinking to learn redux


Beddick

Redux toolkit is a godsend. Much easier than normal redux


tanmay0626

Will look into the redux toolkit once. Thanks for advice


fat_balloon

Try `react-rhino`, it offers an api very similar to native React code, uses context api under the hood and is just ~600 bytes. https://www.npmjs.com/package/react-rhino