Comments (6)
Hey @levipro sorry for the issue! This is a valid issue that we've been discussing with our team to provide a proper solution. We're passing the router parameters (parameters and query string) to the data providers with meta
property and it's also used in the query keys. We've discussed about having a prop or a config to prevent router values to be included to the meta
which user can then decide whether they should be included or not 🤔 We've also discussed to always remove the known parameters from the meta
such as parameters from syncWithLocation
like in this case.
I'll provide an update here as soon as we decide on the changes and working on the implementation. Please do not hesitate share if you have any ideas and comments on this.
from refine.
It looks like the issue might be related to how the useDataGrid
hook handles the synchronization of sorting information with the URL when syncWithLocation
is set to true. The described behavior indicates that the initial request is triggered correctly, but then a duplicate request is made due to the way the sorting information is included in the meta data.
To address the issue, you can try modifying the handleSortModelChange
function in the useDataGrid
hook. Specifically, you can update the function to immediately sync the sorting information with the URL when the sort model changes, preventing the need for a second request.
Here's a modified version of the handleSortModelChange
function:
const handleSortModelChange = (sortModel: GridSortModel) => {
const crudSorting = transformSortModelToCrudSorting(sortModel);
setSorters(crudSorting);
// Immediately sync the sorting information with the URL
if (syncWithLocationProp) {
const link = createLinkForSyncWithLocation({ sorters: crudSorting });
window.history.replaceState({}, "", link);
}
};
This modification should update the URL immediately when the sorting model changes, avoiding the need for an additional request. Make sure to test this change in your application to ensure it resolves the described issue.
Will it create any other issue if we modify the code in that way @BatuhanW @aliemir ?
from refine.
Hello @Conqxeror thanks for the investigation, it looks great!
I think we need to confirm that duplicate request isn't caused by strict mode, see our FAQ here: https://refine.dev/docs/guides-concepts/faq/#why-are-api-calls-triggering-twice cc @levipro
from refine.
Hello @levipro, are you using Next.js?
Yesterday we released new version of @refinedev/nextjs-router
and we believe this issue is fixed.
Can you upgrade @refinedev/nextjs-router
to @5.5.7 and try again please?
from refine.
Hey @levipro sorry for the issue! This is a valid issue that we've been discussing with our team to provide a proper solution. We're passing the router parameters (parameters and query string) to the data providers with
meta
property and it's also used in the query keys. We've discussed about having a prop or a config to prevent router values to be included to themeta
which user can then decide whether they should be included or not 🤔 We've also discussed to always remove the known parameters from themeta
such as parameters fromsyncWithLocation
like in this case.I'll provide an update here as soon as we decide on the changes and working on the implementation. Please do not hesitate share if you have any ideas and comments on this.
Hello, @aliemir. Just wanted to chime in that I'm facing this issue too, but my use case is a bit different.
I'm using useDataGrid
with another hook that also has syncWithLocation
(useModalForm
from @refinedev/react-hook-form
). It's a list page with create/edit/show modals for the resource.
What happens is that the modal adds a modal-<resource>-create
query to the params when it's open, and it gets included in the meta like you said, which causes the table to refresh.
In this case, the second solution you mentioned (automatically removing known parameters) might not work.
from refine.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from refine.
Related Issues (20)
- [BUG] finefoods-client Sample is broken HOT 2
- [BUG] useNotificationsProvider mui anchor position hard coded HOT 6
- [BUG] - refine build is failing HOT 13
- [FEAT] Antd | Allow translation for required field messages HOT 2
- [BUG] error when trying to implement multiple top level `conditionalFilter` using useTable from @refinedev/react-table HOT 2
- [FEAT] Support the dynamic meta parameters when submitting HOT 1
- [BUG] MUI useDataGrid setFilters HOT 5
- [FEAT] Passing arbitrary graphql variables to hasura dataProvider HOT 7
- [BUG] appendCurrentPathToQuery on Authenticated HOT 2
- [DOC] Browser view crashes in Tutorial HOT 3
- [FEAT] Unable to highlight non-CRUD page on menu item HOT 4
- [FEAT] Unable to configure non-CRUD pages in i18n configuration file HOT 4
- [BUG] `mutationOptions` are overriding Refine's behavior unexpectedly
- [DOC] Edit for readability and grammar HOT 3
- [BUG] `useFieldArray` options dissapear after routing away and back to edit page HOT 2
- [BUG] MUI Inferencer sets all fields to required HOT 1
- [BUG] Exmaple project cannot view HOT 3
- [BUG] nextjs 14 upgrade breaks imports HOT 4
- [FEAT]: Supabase Data Provider should filter array column by array HOT 5
- [FEAT] Support TypedDocumentNode for GraphQL data-provider HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refine.