Closed mtt-artis closed 6 months ago
I like the idea here. Only question. I noticed that this doesn't merge with the existing location.search. Is there a reason that passing the function form would have different expectations on what the returned value does?
Hello @ryansolid 👋 I'm not sure I understand the question (sorry for my bad English) I made this PR after reading this issue https://github.com/solidjs/solid-router/issues/328 I'm on holiday without my pc right now but I can check the merge conflict this weekend
I see the problem now. This was always a merge instead of a set. Which is a bit awkward. Hence why you made the function a set rather than a merge, because the consumer could always do the merge as they saw fit. But it's inconsistent.
Realistically it should have never been merge I think. Solid Stores blur the line but I think it is confusing in general. However, if it weren't a merge the function form would have always been the one that would have made sense. Ironically I probably wanted it to merge originally for ease of use.
In any case, this probably should go one way or the other.
feat: Enable passing a function to
setSearchParams
for dynamic search updatesThis commit introduces a new enhancement to the
useSearchParams
hook, allowing thesetSearchParams
function to accept a callback function as an argument. By passing a function instead of a plain object tosetSearchParams
, developers can now perform dynamic search updates based on the current search parameters. The callback function receives the existing search parameters as its argument, and it should return an updated search parameters object. This feature enables more flexible and dynamic search functionality, empowering developers to easily handle complex search scenarios and update search parameters in a controlled manner.https://github.com/solidjs/solid-router/issues/328