Hook Function

Loading "Hook Function"
๐Ÿ‘จโ€๐Ÿ’ผ We now want to create a reusable useSearchParams function which will handle the search params for us generally so we can use that logic in other components.
There's a much more complete version of this hook as a part of react-router which you'll likely want to use in a real application. This is just a simple example.
So your job is to take the logic from the App component that relates to the search params and put it in a new function called useSearchParams, then you'll use that function in the App component.
const [searchParams, setSearchParams] = useSearchParams()
For the types of that tuple, you may find this article helpful: Wrapping React.useState with TypeScript
There are actually not a lot of lines changed in this step of the exercise, but we're going to be bringing in useCallback in the next step so keep going!
๐Ÿšจ this is just a refactor so the tests are passing already, you just need to make sure they don't fail!
Good luck!
Login to get access to the exclusive discord channel.
  • General
    Welcome to EpicReact.dev! Say Hello ๐Ÿ‘‹
    Kent C. Dodds โ—† ๐Ÿš€๐Ÿ†๐ŸŒŒ:
    Welcome to the first of many posts in the EpicReact.dev channel! Take a moment to introduce yourself...
    0 ยท 3 days ago