Resetting the State
We'll cover the following...
While we’ve made it easier for the user to dictate the initial state within the custom hook, they should also be able to reset the state to the initial state at any point in time, i.e., a reset
callback they can invoke to reset the state to the initial default state they provided.
This is useful in many different use cases.
Why Reset the State?
Let’s consider a really trivial example.
Assume the terms and conditions content in the user app was so long that they changed the default expanded state to false
, i.e., the expandable content isn’t open by default.
Since the content was long, they decided to provide a button towards the end of the write-up. A reader could click to revert the expandable content to the initial closed state for which they may ...