S
SolidJS10mo ago
vik

Update searchParams with useNavigate

I have a couple of tables. I can select rows of the table and add my rowId's to queryValue here is a simplified version of my code
const navigate = useNavigate();

createEffect(() => {

navigate("/?query=" + selectedIds().join("|"), { resolve: false });
})
const navigate = useNavigate();

createEffect(() => {

navigate("/?query=" + selectedIds().join("|"), { resolve: false });
})
This works fine so fare. Better than with searchParams. With searchParams I had the problem, that the value was URLencoded, but I want to keep | And useNavigate allows me push the changes to browsers history. Problem: everytime I select a row, or evertime that Effect is triggred, the browser jumps to the top. I don't want navigate to reload. So a mix of searchParams and navigate would be good?
2 Replies
thiccaxe
thiccaxe10mo ago
you can have multiple, like ?query=a&query=b
vik
vik9mo ago
I am not sure if that would be the solution. Hence i have also other query params and the selection of items could be long, i prefer to keep the query string small. Any change triggers browsers attention to jump to the top of the page