Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best approach to design state? #1825

Closed
mihir0x69 opened this issue Jun 24, 2016 · 2 comments
Closed

What is the best approach to design state? #1825

mihir0x69 opened this issue Jun 24, 2016 · 2 comments

Comments

@mihir0x69
Copy link

mihir0x69 commented Jun 24, 2016

State for TodoApp was pretty straightforward. However, as you go on exploring other examples, the state becomes a little confusing. What is the best way to design state for a complex application?

In shopping cart example, the original result from API call was an array. But it later was converted into an object with keys as IDs. What is the significance of that? Is storing state as an array discouraged? I understand that the design of the state may vary according to the use-case. But is there any general rule of thumb to design state in order to manage it in a painless manner?

After 2 weeks of banging my head, I finally wrapped my head around how redux operates. However, designing the state is even mind-boggling.

If you point me to a pertaining article, that will also do.

@leoasis
Copy link
Contributor

leoasis commented Jun 24, 2016

Hi @mihir-harbinger! This question is answered in the Reducers section of the docs, check the note below "Designing the State Shape" section.

Hope that helps!

@markerikson
Copy link
Contributor

markerikson commented Jun 24, 2016

This qualifies as a usage question, and should really be asked on Stack Overflow instead.

That said, the Redux FAQ covers some of these topics, such as http://redux.js.org/docs/FAQ.html#organizing-state-nested-data . Dan's new "Idiomatic Redux" video series includes a lesson on "Normalizing the State Shape". I'm also hoping to write a recipe page shortly on "Structuring Reducers" - current discussion and plans are over at #1784 . The list of real Redux-based apps shows a number of real-world examples that could be informative. Finally, my list of links to React/Redux tutorials and articles has relevant articles as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants