Skip to content

Commit

Permalink
fix instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 14, 2024
1 parent 01a56d8 commit ca7f2b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exercises/03.custom-hooks/02.problem.callback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function useSearchParams() {
return () => window.removeEventListener('popstate', updateSearchParams)
}, [])

// 🐨 wrap this function in useCallback
function setSearchParams(...args: Parameters<typeof setGlobalSearchParams>) {
const searchParams = setGlobalSearchParams(...args)
setSearchParamsState(prevParams => {
Expand All @@ -36,6 +37,7 @@ function useSearchParams() {
})
return searchParams
}
// 💰 note, this function doesn't have any dependencies so you can use [] as the dependency array

return [searchParams, setSearchParams] as const
}
Expand Down

0 comments on commit ca7f2b8

Please sign in to comment.