do i have to store every data redux

313

It depends on the use case:

Imagine that you have some kind of input form with multiple text fields, checkboxes, a date picker and a submit button, with trivial validation. In that case it might be easier to manage the state locally in a StatefulWidget. On submit, you would insert the data into the redux store.

On the other hand, when the manipulated form input is directly visible in other parts of the app (e.g. editing entries without a submit button) while the user is editing it, you would put everything into the store. That also enables you to easily implement undo/redo.

You also have to ask yourself if you actually need redux. If your app only consists of isolated screens and there is no need to transform or combine data, you may not need redux.

Another solution would be multiple redux stores. For example, you could have one permanent store for entities/submitted data, and temporary stores which handle form validation in a specific screen of your app. Those temporary stores would be discarded when the user leaves the screen.

Share:
313
LootyMcLootenstein
Author by

LootyMcLootenstein

Updated on December 06, 2022

Comments

  • LootyMcLootenstein
    LootyMcLootenstein over 1 year

    I am new to redux so i have a few questions that i hope tu get answered. It would be very nice if you could explain something about building a redux architecture.

    At this time I write to App with Flutter, using the Flutter_Redux package (https://pub.dartlang.org/packages/flutter_redux).

    Now my question:

    Do I have to store all possible values/datafields ​​(e.g. user input in a textfield) in the redux store?

    Because of reloading actual screen the values ​​disapear. In my case I use the showDatePicker() Function (https://docs.flutter.io/flutter/material/showDatePicker.html) and I don't know how I should to handle the return Value.

    Sorry for my bad english. I hope you understand my problem.

    • Günter Zöchbauer
      Günter Zöchbauer almost 6 years
      I think this depends on the actual use case, but I prefer to have all state in Redux except perhaps state that is only related to behavior of a widget and only needed temporarily.
    • LootyMcLootenstein
      LootyMcLootenstein almost 6 years
      It would be very nice, if you can give me an example of this.
  • Mahesh Bhattarai
    Mahesh Bhattarai almost 5 years
    How to handle temporary store