score:2
Accepted answer
from the github issue, find this comment
this is a known quirk due to the implementation details of concurrency in react. we don't cheaply know which of two versions is currently committed. when this ambiguity happens we have to over render once and after that we know that both versions are the same and it doesn't matter.
so we cannot help the component in question but we can help the children from not getting affected.
how?
use react.memo.
the component children would therefore not get affected by the second, useless re-render.
Source: stackoverflow.com
Related Query
- Why is the componet being re-rendered twice?
- Why this event handling function is being called twice and updates the state twice in react?
- Component making axios request being mounted twice in order for asynchronous test to pass, if it is mounted once the test fails. WHY
- Why does this custom hook rendered twice even though the state hasn't changed?
- Why is the API response not being rendered by useState?
- Why is my state variables being rendered twice in reactjs
- Why is `Promise.then` called twice in a React component but not the console.log?
- Why is my function being called twice in React?
- Why isn't the Formik `touched` property being populated?
- Why my font-awesome icons are being displayed big at first and then updated to the right size?
- Why does useState cause the component to render twice on each update?
- Why is this component being rendered after throwing an error?
- Why is only the last item in a map function being changed in react app?
- Why is a ReactJS component using Hooks rendered once or twice depending on developer console is open or not?
- Why is the Redux store being updated with a duplicate nested key?
- React Infinite Scroller - Two children with the same key. loadMore function being called twice
- Why does setState Hook from React is rendering twice even not changing the state?
- Why does the render function in react is called twice when using the component strategy?
- In react class component why is the state not being changed in the first instance of button click? But in the second instance it gets updated?
- Why doesn't <Table/> show the check box when rendered multiple times?
- Why is initial state being set over and over again in the "useState" hook of react
- Collect Data from the same component which is being rendered multiple times into an array to be sent to the server
- How to reload the Data of a child when a child Component is being rendered in ReactJs
- Why doesn't the loader show on the second test when I run the same test twice in jest, using react testing library, react.lazy, and suspense?
- Why is axios being called twice in my program
- Why value from a Material-UI Button is not being passed to the onClick event handler?
- Why does react re-render twice when using the state hook (useState)?
- Basic React: why is a variable in local storage resetting to undefined after briefly being the desired value?
- React: Why are these components not updated when useState changes? (components rendered after the app is mounted)
- Why is setInterval not being cleared in REACT the same way as it is in vanilla JS
More Query from same tag
- pass id and value to set of select input in react js
- Is it OK to use unique, stable functions (e.g. components) rather than strings as React keys?
- Unable to get value of persisted state using redux-persist after the store is rehydrated
- HTML drag & drop in react -- seeing the same id at target, srcElement, and toElement?
- How to restrict date selection in React native ios/android datepicker
- onload function only displays one result (I think the last item in the list) x number of times
- Redux-React: value returned by a dispatch function is not being passed to child component
- trying to delete from an API using axios and React hooks
- How to test an onChange input event with enzyme and jest
- Webpack5 + react-refresh-webpack-plugin does not work
- React JS event handler arguments
- Is there any way to use JSX or similar with Backbone?
- Infinite rerendering loop when using information from refs to set state
- Need help in fetching document with reference id in firestore using reactjs
- Axios request returning promise Object
- Await react router history.goBack
- How to test a handle function call with a react functional component with hooks
- Testing Multiple useState hooks onClick With Jest, useRef?
- Rotating an image *before* rendering?
- Embed Typeform into React using Custom Button Component
- Axios Excel file download using POST results in corrupted file
- How do I deal with promises in setState?
- React + Docker + Nginx
- How to fix the bug React-Redux: Actions must be plain objects. Use custom middleware for async actions? I need clarity on the same
- Adding and Removing Data from/to State in Redux/React using Lodash
- State value `undefined` on state onChange
- How to set host environment variables inside npm scripts(package.json)
- How to do gzip most efficiently in express react app made using nextjs framework and hosted on heroku
- How to access props.match.params in functional components
- React change content based on item selected in Dropdown