I am using Redux. Should I manage controlled input state in the Redux store or use setState at the component level?

前端 未结 5 1800
予麋鹿
予麋鹿 2021-01-30 10:09

I have been trying to figure out the best way to manage my react forms. I have tried to use the onChange to fire an action and update my redux store with my form data. I have al

5条回答
  •  自闭症患者
    2021-01-30 10:45

    Personally, I highly recommend keeping everything in the Redux state and going away from local component state. This is essentially because if you start looking at ui as a function of state you can do complete browserless testing and you can take advantage of keeping a reference of full state history (as in, what was in their inputs, what dialogs were open, etc, when a bug hit - not what was their state from the beginning of time) for the user for debugging purposes. Related tweet from the realm of clojure

    edited to add: this is where we and our sister company are moving in terms of our production applications and how we handle redux/state/ui

提交回复
热议问题