Do I need a Flux Store for this purpose?

Let's say I have a simple form component for posting a tweet. Why do I want to create a repository to preserve the state of the form, instead of just declaring the state in the getInitialState () of my form component? After the user has typed the form and clicks submit, then we only update the state and call the backend api? Why am I having trouble setting up actions and listeners? Thanks for watching this!

+4
source share
1 answer

The short answer is no. A simple reaction component can be completely self-sufficient.

The long answer is that it depends on whether this component coexists in a larger application.

If published tweets force you to update any other component, you will need some form of communication to handle this. This can be a simple function or a callback for a small number of components and dependencies. But as the application grows, the cascade of dependencies will grow with it, and the discussion of several components becomes more difficult. The "flow" pattern is a proven way to solve this problem.

My advice: Start small and keep state and components simple, refactor as needed.

+2
source

All Articles