GithubHelp home page GithubHelp logo

Comments (6)

aliemir avatar aliemir commented on June 15, 2024 1

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.

Conqxeror avatar Conqxeror commented on June 15, 2024

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.

Link to that specific code.

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.

BatuhanW avatar BatuhanW commented on June 15, 2024

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.

alicanerdurmaz avatar alicanerdurmaz commented on June 15, 2024

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.

suphon-t avatar suphon-t commented on June 15, 2024

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.

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.

stale avatar stale commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.