rare-sapphire
rare-sapphire8mo ago

Disable Router Query Params?

I'm upgrading to Refine v4 and the latest React Router v6 with BrowserRouter. Somehow there are new filter parameters being passed along and injected into my dataProvider hooks, and they are usually invalid filters. How can I turn those off?
7 Replies
kapa.ai
kapa.ai8mo ago
Hi @geoffatsource. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In Refine v4, you can disable server-side filtering by setting the filters.mode to "off" in the useTable hook. Here's how you can do it:
useTable({
refineCoreProps: {
filters: {
mode: "off",
},
},
});
useTable({
refineCoreProps: {
filters: {
mode: "off",
},
},
});
This will prevent any filter parameters from being passed to your dataProvider hooks. For more information, you can refer to the Refine React Table documentation (https://refine.dev/docs/packages/documentation/react-table/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8mo ago
<@1014305963219615754> kapa.ai is still learning and improving, please let us know how it did by reacting below
rare-sapphire
rare-sapphire8mo ago
@kapa.ai I want to disable query parameters globally in my app to prevent query string injection
kapa.ai
kapa.ai8mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- In Refine, you can disable query parameters globally by setting the syncWithLocation option to false in the <Refine> component. This will prevent the list of query parameters from being modified manually by editing directly in the URL. Here's how you can do it:
import { Refine } from "@refinedev/core";

const App: React.FC = () => {
return (
<Refine
// ...
options={{
syncWithLocation: false,
}}
>
// ...
</Refine>
);
};
import { Refine } from "@refinedev/core";

const App: React.FC = () => {
return (
<Refine
// ...
options={{
syncWithLocation: false,
}}
>
// ...
</Refine>
);
};
For more information, you can refer to the Refine documentation (https://refine.dev/docs/core/components/refine-config). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8mo ago
<@1014305963219615754> kapa.ai is still learning and improving, please let us know how it did by reacting below
exotic-emerald
exotic-emerald8mo ago
Hello @geoffatsource was the bot's answer sufficient for you?
rare-sapphire
rare-sapphire8mo ago
Yes thanks