Git Product home page Git Product logo

Comments (4)

timdorr avatar timdorr commented on September 27, 2024

Loader data is not compared for strict equality because we don't know the full structure of the data. It's often times something coming from an external data source (an API or database) that may have changed outside of the application and cannot be assumed to be the same.

You are also technically creating a new object every time you call return { results: "Hello World" }, so that wouldn't be strictly equal (i.e., { results: "Hello World" } !== { results: "Hello World" })

As a result of this, when you submit the form, we are re-running the loader and returning the data as a new instance back to the component. This happens any time the loader is re-run. It's very common for a <Form> action to modify the contents of the loader data, so we have re-run it to ensure it's in sync with anything external.

from react-router.

julienw avatar julienw commented on September 27, 2024

Hey @timdorr , thanks for your answer ! I think there's a misunderstanding.
I'm totally fine with 1 render, as I understand the constraints we're dealing with. However I see not 1 but 2 renders when clicking on the button: 1 right away, 1 after the loader runs. You can add a timeout to the loader or add more logs to check this further.
It would be good to reopen the bug, please :-)

from react-router.

timdorr avatar timdorr commented on September 27, 2024

#11134 (comment)

from react-router.

julienw avatar julienw commented on September 27, 2024

yes, I understand this is expected due to how things work internally, but I don't understand why this would be expected from the library user point of view.
I haven't worked much with contexts in the past, maybe the "state" and the "data" should be in 2 different contexts rather than the same one?
Thanks for your consideration.

from react-router.

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.