rival-black
rival-black2y ago

use router v6 with search params

Hello 👋 i am trying to programmatically redirect to the create view of a resource and passing some search params. My code is redirecting correctly but there are no search params in the url:
import { useNavigation } from "@pankod/refine-core";
...
const { push, goBack, createUrl } = useNavigation();
...
const customSubmit = (values: FieldValues) => {
// push to path with query params
push(createUrl(resourcename), { search: '?sort=date&order=newest'})

}
import { useNavigation } from "@pankod/refine-core";
...
const { push, goBack, createUrl } = useNavigation();
...
const customSubmit = (values: FieldValues) => {
// push to path with query params
push(createUrl(resourcename), { search: '?sort=date&order=newest'})

}
Can someone point me in the right direction? Thank you
5 Replies
quickest-silver
quickest-silver2y ago
@zomh Hi, I will debug and inform you 🙏
rival-black
rival-black2y ago
@alicanerdurmaz thanks mate this is my package json version: "@pankod/refine-react-router-v6": "^3.36.2",
quickest-silver
quickest-silver2y ago
@zomh Sorry for your trouble, I guess we have bug on push() function's type can you use like this now ? we will discuss on monday with the core team and we will fix.

// @ts-ignore
push({ pathname: createUrl(resourceName), search: '?sort=date&order=newest' })

// @ts-ignore
push({ pathname: createUrl(resourceName), search: '?sort=date&order=newest' })
rival-black
rival-black2y ago
@alicanerdurmaz yea sure. thanks for checking. that works for now
quickest-silver
quickest-silver2y ago
i will inform you again when we fix types 🙏