A
A
Artemmmm132021-01-10 17:52:11
React
Artemmmm13, 2021-01-10 17:52:11

Is managing a form in react via local state a violation of the flux architecture?

I just recently started learning frontend and react in particular, now I'm practicing react + redux. When I was studying (now continuing to study), it was clearly hammered into my head that the flux architecture should be respected, that is, changes in the UI should occur only after changing the global state. But what about working with forms, is it a violation of this architecture if instead of redux state for form processing, use local state ? I know that there is a special redux-form library for this, but it seemed to me not convenient. I could not find a definitive answer to this question (Correct if I made a mistake in the wording of the question)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2021-01-10
@Artemmmm13

In general, you should not blindly follow flux and shove everything into a global state (in the case of redux).
If your state is shared - used by several components and so on, then yes, it should be put in the state application, but if you have a form and it just goes to the server - then what's the point of this data in the store?
Let's take a standard example - user data (settings, name, etc.), it makes sense to store them in the global state, since they are used in many places.
in general, I personally adhere to the following:
Is this state shared (or will the mb be shared)?
- yes => store in store
- no => store in local state

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question