2

Redux state management for Text-Inputs

Can we keep the states of text-inputs in reducers and update directly in store ?

As per my understanding states like these must be at component level because updating store onChange may cause performance issues.

LuFFy
  • 8,799
  • 10
  • 41
  • 59
  • 4
    Start with keeping the state in the component and then if you have a specific requirement, say you show some error/good state for input in some other part of the UI, move it to redux. – Mukesh Soni Aug 08 '18 at 05:47
  • @MukeshSoni no actually i dont need to show errors or anything like that. Is it good idea to dispatch events on every change and update store ? – imbudhiraja Aug 08 '18 at 05:49
  • Nope. You probably don't need that. – Mukesh Soni Aug 08 '18 at 05:52
  • @v8-E he's not asking for code, nor talking about a *specific* code issue. It's a design question. In response to OP, values that need to be shared between different parts of the app should go in the store, otherwise they should be kept at the component level – Jayce444 Aug 08 '18 at 05:56

2 Answers2

0

To avoid performance issues, use debounce. Please visit this post or this post for a detailed answer.

gazdagergo
  • 6,187
  • 1
  • 31
  • 45
0

Not necessary as it causes your app performance badly.And having said that, if you want to access the input text from various components in the app then storing the values in the reducer is a good choice.

There is a famous package called redux-form which dispatches the actions on every keydown.This really helps in real time form initialization or manipulating the value entered.

CodeZombie
  • 2,027
  • 3
  • 16
  • 30