You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases, it makes sense to use unidirectional data flow like Redux to manage state at the root of a component tree (e.g. a stopwatch app). However, in certain cases it's useful to have local component state. In the React world, the utility of local state has been proven time and again, see this thread Question: How to choose between Redux's store and React's state? #1287.
For example a spinner. A spinner needs to use a timer to re-render itself as it spins. Also, the spinner is the only thing that will be using this timer, and its time elapsed (it "owns the datum"), so it doesn't make sense to put it in the state of the Redux store.
Therefore this library needs to have local state, similar to React's local state. Therefore it also needs to have lifecycle hooks, create and destroy.
Here's an API sketch for what local state could look like.
In most cases, it makes sense to use unidirectional data flow like Redux to manage state at the root of a component tree (e.g. a stopwatch app). However, in certain cases it's useful to have local component state. In the React world, the utility of local state has been proven time and again, see this thread Question: How to choose between Redux's store and React's state? #1287.
For example a spinner. A spinner needs to use a timer to re-render itself as it spins. Also, the spinner is the only thing that will be using this timer, and its time elapsed (it "owns the datum"), so it doesn't make sense to put it in the state of the Redux store.
Therefore this library needs to have local state, similar to React's local state. Therefore it also needs to have lifecycle hooks, create and destroy.
Here's an API sketch for what local state could look like.
More motivation for renaming
d
toprops
.The text was updated successfully, but these errors were encountered: