|
|
|
|
|
by bern4444
1553 days ago
|
|
No array means execute the hook on every rerender of the component. Empty array means execute the hook once on initial render. Non empty array means execute the hook when the value of anything in the dependency array changes. These are pretty simple to remember imo. An alternative design could have been to pass in an object as a second parameter instead of an array with these options details like { runOnlyOnInitalRender: true }
Or { alwaysExecuteOnRerender: true }
Etc. But that feels far more verbose than the three options we have now. |
|
But why should we? No other reactive framework makes the developer go through this ritual. Even RxJS is clearer to understand.
> Etc. But that feels far more verbose than the three options we have now.
A better designed API would require neither.