Custom React hook that updates the state only once when the current value matches the target value.
This hook is useful for setting a state based on a condition that only needs to be fulfilled once.
When the currentValue equals the targetValue, it sets the state to the targetValue.
Custom React hook that updates the state only once when the current value matches the target value.
This hook is useful for setting a state based on a condition that only needs to be fulfilled once. When the
currentValue
equals thetargetValue
, it sets the state to thetargetValue
.Example