0

I stuck on the way to keep the workout data in a session in local storage

The situation is; that there is a bunch of input text taking "weight" and "reps" from the users.

<TextInput
        style={addItemStyles.input}
        // value={weight}
        onChangeText={(e) => setweight(e)}
        keyboardType="number-pad"
        returnKeyType="done"
      />
 
  <TextInput
    label="Reps"
    style={addItemStyles.input}
    // Value={reps}
    onChangeText={(e) => setReps(e)}
    keyboardType="number-pad"
    returnKeyType="done"
  />

in a single exercise, I want to take 3 sets (Weight & reps) and save them into an array.

settotalSet((current) => [...current, data]);

Then I need to keep several sets of data like this but belong to other exercises

I need to hear your advice to choose the best way to keep this data accessible in app during the workout session.

Do I have to use useReducer, use context, or Redux

Vahid Afshari
  • 49
  • 1
  • 5

1 Answers1

1

In my opinion, if you have a big application with a lot of data to be passed along the screens then it will be good to use redux. Yes! it has the overhead of managing a lot of boilerplate code but in the long run, it will be more organized and easier to manage. In the future, if you need to persist data that will be easier with redux-persist. The screenshot below shows how it will look once you create separate reducers (you can store data as arrays as well). Example redux