Flux: where should intermediate errors be stored?

The Flux documentation states that state should be kept in stores. Should the entity-related error messages be stored afterwards, stored in stores. Since the View will receive its initial state from the store, so you can only find out if its loading / saving comes from the store.

Also when editing the form, the user decides to undo the edit, so should these intermediate form values ​​be stored in the Views states and then submitted to the Store?

+3


source to share


2 answers


Your input fields should have their own memory. This means that the Store state (the source of truth) is invariably separated from any changes that take place in the components. Actions communicate these changes to stores. Whether they are new true or not erroneous, the Store state will again be invariably copied to the component's input state. Errors, I will also go to the component as they apply to the input state, not the saved state.



Stores are like databases, you rarely put any temporary records or errors there. Unless you've written a text editor that tracks your input history ...

0


source


I use React in a very functional way, since all my data is stored outside of React as a global JSON object, and this data is injected into the top level component. So React is just a clever templating engine for me: converting JSON to Virtual DOM and then Applying Virtual DOM to real DOM. Rendering is always started from the main component and is optimized by immutability. More details here

I disagree with Rygu, bugs are part of the state. Stores can be comparable to databases, but what does that mean? That stores should only contain what is not "temporary" or something that might be considered meaningless?



For me, if you want to enable functional programming with React, anything that appears as DOM should rather be passed as props to your components in the first place, including errors. If you don't, you will rely on side effects to manipulate the DOM, and over time it will become more difficult to reason about all of these side effects.

+1


source







All Articles