rival-black
rival-black13mo ago

How to pass parameters in go method of useGo?

I want to pass some values in go method of useGo and use them in the other component. How can I do this?
2 Replies
kapa.ai
kapa.ai13mo ago
Hi @saarthak08. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The useGo hook in Refine allows you to perform navigation operations. You can pass values to the go method by using the query parameter. The query parameter is an object that you want to add to the path as query parameters. The routerProvider will convert this object to the query string. Here is an example of how you can use the useGo hook to pass values:
import { useGo } from "@refinedev/core";

const MyComponent = () => {
const go = useGo();

return (
<Button
onClick={() => {
go({
to: "/posts",
query: {
filters: [
{
field: "title",
operator: "contains",
value: "Refine",
},
],
},
type: "push",
});
}}
>
Go Posts With Default Filters
</Button>
);
};
import { useGo } from "@refinedev/core";

const MyComponent = () => {
const go = useGo();

return (
<Button
onClick={() => {
go({
to: "/posts",
query: {
filters: [
{
field: "title",
operator: "contains",
value: "Refine",
},
],
},
type: "push",
});
}}
>
Go Posts With Default Filters
</Button>
);
};
In the above example, the go method is used to navigate to the "/posts" path and it also passes a filters query parameter. In the component you navigate to, you can access these query parameters from the URL. For more information, you can refer to the useGo documentation (https://refine.dev/docs/api-reference/core/hooks/navigation/useGo). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@783220602336444416> kapa.ai is still learning and improving, please let us how it did by reacting below