Comments (4)
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.
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.
from react-router.
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)
- [Bug]: child loader redirect overrides parent loader error HOT 7
- [Bug]: v7_partialHydration with unstable_patchRoutesOnMiss: hydrateFallbackElement not shown on patched routes HOT 5
- [Bug]: Relative path does not work as expected in outlets HOT 1
- [Bug]: useNavigate causes component to rerender HOT 6
- [Bug]: react-aria-components Link - wrong href for external links integrating with React Router HOT 1
- [Bug]: HashRouter need to wrapped twice HOT 1
- [Bug]: returning `replace` from loader replaces an extra entry HOT 8
- [Bug]: When the page returns, there is a noticeable delay/latency. HOT 1
- [Bug]: Navlink className function props not work as expected it HOT 2
- [Docs]: Switched parameters in matchPath HOT 1
- [Bug]: Unable to match a url that ends in an equal sign HOT 1
- [Bug]: optional segments with dynamic segments HOT 1
- [Bug]: State is not preserved in a component tree when switching to render via custom `<Routes location={location}>` prop
- [Bug]: undefined is not an object (evaluating ' request.signal.aborted ')
- [Bug]: "TypeError: URL constructor: // is not a valid URL" while using data router HOT 9
- [Bug]: Relative option is not work in useNavigate HOT 3
- [Bug]: (a11y)-Multiple accessibility issues with React-Router HOT 1
- [Bug]: The global state manager does not work in conjunction with react-router-dom HOT 1
- [Bug]: encoded # in path parameter causes route to be evaluated differently
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 react-router.