date | published | categories | tags | ||
---|---|---|---|---|---|
2023-09-08 |
true |
notes |
|
- Functions must be pure (or at least functionally "pure").
- Hooks must fire in the same order, every time.
- Only call Hooks at the top level (in order to satisfy rule #2). Don’t call Hooks inside loops, conditions, or nested functions.
- State will be preserved between re-renders.
- Does not merge state values with the state setter! You need to merge on your own.
- The only argument is the initial state.
- Initial state is only set and executed on first render.
- Returns values in the order you initialized them, which is why the order of execution must not change.