I have a react component and I want to perform an action if it has focus for 2 seconds. In pure react I had internal state where I could handle this. What is the approperate way to do it using Redux?
Asked
Active
Viewed 144 times
0
-
1Sounds like you need something like: http://stackoverflow.com/questions/35411423/how-to-dispatch-a-redux-action-with-a-timeout/35415559 – lux Aug 24 '16 at 21:17
1 Answers
0
Use React for ephemeral state that doesn't matter to the app globally and doesn't mutate in complex ways. For example, a toggle in some UI element, a form input state. Use Redux for state that matters globally or is mutated in complex ways. For example, cached users, or a post draft.
Sometimes you'll want to move from Redux state to React state (when storing something in Redux gets awkward) or the other way around (when more components need to have access to some state that used to be local).
The rule of thumb is: do whatever is less awkward.
https://github.com/reactjs/redux/issues/1287
This is the answer by Dan Abramov creator of Redux.
In your case, I think it's OK to use React component state.

Dmitriy Nevzorov
- 6,042
- 1
- 20
- 28