Set state function which called "setValue" of useState of React,
but it goes through a "canUpdate" function before the state is actually set.
The "canUpdate" function can determine whether the next state should be set.
Example use case: There are multiple forms, while only one form can be open each time
Parameters:
Name | Type | Description |
---|---|---|
nextValue |
The next value to be set, e.g. "isOpen" state. | |
setValue |
The React state setter for setting the "nextValue", .e.g. "setIsOpen". | |
canUpdate |
The function which receives the "nextValue", to return a boolean indicating whether the update is allowed. |