How would you propose changing state of a hook based on the prop passed to it?
An example would a count-down timer with reset functionality. If we're passing some future time to this custom hook, then the hook needs to update its internal state as well.
yes I think you're right. a hook's state should not depend on its props. it should be private and it should expose functions that trigger hook's state change so that we have more control over hook's state. thanks.
How would you propose changing state of a hook based on the prop passed to it?
An example would a count-down timer with reset functionality. If we're passing some future time to this custom hook, then the hook needs to update its internal state as well.
You define state inside the hook and return setValue and value from the hook, just like useState does you don't pass state to hook.
yes I think you're right. a hook's state should not depend on its props. it should be private and it should expose functions that trigger hook's state change so that we have more control over hook's state. thanks.
In hooks props are often used for state initialization: