Skip to content

Examples/conventions around transient local state #718

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

Closed
ashaffer opened this issue Sep 13, 2015 · 4 comments
Closed

Examples/conventions around transient local state #718

ashaffer opened this issue Sep 13, 2015 · 4 comments

Comments

@ashaffer
Copy link
Contributor

Are there any established patterns for this?

E.g. dropdowns/modals, and things like that. Where the application potentially has some dynamic number of them scattered around, and you need to:

  • localize the information on state somehow
  • propagate the information to the correct components, that are potentially deeply nested

There is another similar issue here: paldepind/functional-frontend-architecture#14 But all of the answers are nonspecific and relatively unsatisfying.

In particular, in my app I have a dropdown, and that dropdown is somewhat deeply nested within other components. I would like to implement its state in a normalized way, so that at the top-level I have a dropdowns property that is a map of ids to dropdown states and then have a DROPDOWN_OPEN / DROPDOWN_CLOSE action with the id as its payload for my actions. The tricky part though is how you go about getting that data to this deeply nested component.

@cesarandreu
Copy link
Contributor

I keep that kind of UI state (e.g. dropdown) in the component's state.

When I have something like a form inside of the modal, I make a container which is passed in through another container. Each form modal has a selector/reducer under state.forms[formName]. Among its properties it has an active property, which is what I use to track the open/close state.

@ashaffer
Copy link
Contributor Author

When you say 'the components state', do you mean the React component's local state, or just localized to the component in your redux state atom? I'd prefer not to keep any state in my actual components, but if you mean the latter i'd be curious how you are going about structuring local component state in your redux state atom.

Also, would you mind going into a little more detail about how you pass the forms down through parents?

@gaearon
Copy link
Contributor

gaearon commented Sep 13, 2015

Related: #159

@gaearon
Copy link
Contributor

gaearon commented Sep 24, 2015

I'll close this as very close to #159, let's continue the discussion there.

@gaearon gaearon closed this as completed Sep 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants