Open itelo opened 5 months ago
Thanks for this
I just got back from Europe today and have a lot this week, so gimme a couple days to review
If I forget feel free to ping me
@ethanniser can you take a look at this? I believe I will need to add react-testing-library to test the hook
sorry I took so long, just had a look and I like it and think it has a place
the stuff I would like to see:
updateSearchParams
to setSearchParams
to match existing api namingsetState
style update function that provides the previous search params
setUrlParams({foo: "bar"})
setUrlParams((prev) => ({ foo: prev.foo + "!" }))
useState
api (open to discussion) or not having seachParams
as a nested object- so basically previous api + updateSearchParams
(would be better for backwards compat if we care about that)
// possible options
[searchParams, setSearchParams] = useSearchParams(Route.searchParams);
{searchParams, setSearchParams} = useSearchParams(Route.searchParams);
{data, isLoading, isError, error, setSearchParams} = useSearchParams(Route.searchParams);
and then will need tests + docs but overall I think this will be a good addition thanks for the contribution
This PR:
I love the idea from https://github.com/ethanniser/next-typesafe-url/issues/84. I added the code needed, and it works as suggested in https://github.com/ethanniser/next-typesafe-url/issues/84#issuecomment-1904482503.
[] ~Yes, I have made a changeset~ Not yet; I want to make sure I'm on the right path before I finish this PR
Missing tests 👀