Your app is using
StrictMode. See your
index.js file - your app is wrapped between a
StrictMode will cause your app to render twice, but only in development mode. Creating an app with
create-react-app will enable strict mode by default.
Here are the official docs for strict mode.
The solution is just to remove
<React.StrictMode>, but that will also disable some of its advantages, so if it doesn't bother you, I'd just leave it as is, knowing it won't render like that in production.
See this related question for more details: My React Component is rendering twice because of Strict Mode
Obviously that re-rendering thing is definitely not a bug, or something related with the library's render mechanism. On the contrary it is a debugging mechanism provided by React 🤗
refer this blog https://mariosfakiolas.com/blog/my-react-components-render-twice-and-drive-me-crazy/ you'll get better understanding .
you can disable strictmode refer this sandbox link.it'll only render once .
- Why does this component render twice in react?
- Why does the render function in react is called twice when using the component strategy?
- Why does useState cause the component to render twice on each update?
- Why does a simple React Component render twice?
- Why does this React component return the string '0'
- Why does React render component for the second time after setting the state to the same value?
- Why does this create an infinite render loop with React hooks?
- Why does react component do not re render after changing state
- what does this assignment means in this render method of a react component
- Why does this component render twice?
- Why does this React component return 9 errors
- Why does my component render twice when using React's Context API and the useEffect hook?
- In this basic react application, why does the custom component `TextInput` allow me to type stuff in even though the regular `input` field doesn't?
- Why does my YouTube React component fire the PlayerState.ENDED event twice before playing the next video?
- Why does my React component not render when using React-Router?
- Functions are not valid as a React child. This may happen if you return a Component instead of from render
- Why does React warn against an contentEditable component having children managed by React?
- Why is `Promise.then` called twice in a React component but not the console.log?
- Why does my React Component Export not work?
- Why does React warn me against binding a component method to the object?
- Why does react class component always need to call super(props) in its constructor?
- Why does null React component state initialization get `never` type?
- Why is this react component rendering twice?
- Why does React dev tools show my component as Anonymous?
- React SVG import as a Component does not render
- bind(): You are binding a component method to the component. React does this for you automatically?
- Why does React strangely render the <p> (paragraph) tag?
- Why memory leak happend and render slowing down when I close and re-open react component (material-table)?
- Does React render the WHOLE component if only one part of the component changed?
- Why is my react component rendering twice on initial load?
More Query from same tag
- Interactive farm maps
- Object cannot render as React Child (Error while using array.filer() method)
- How to reset location state in react router
- setInterval/setTimeout might be causing page reload
- How to hide error message and only highlight field in yup test
- React - State is not updating when it is supposed to, why is react doing this? (not retaining)
- coding reactjs with the build in of html
- Convert date using react-moment
- Read data from request which just finished
- Create the same ref functionality in React Function component as in React Class component
- React Native memory leak react native gesture handler
- Alignment of the component in reactJS
- Run two Redux Actions consecutively + Typescript
- React+Redux - Expected the reducer to be a function
- Missing styles when using React with Web Components
- Trying to use react-materialize component in Gatsby.js, get ReferenceError: $ is not defined
- How to set the color of the clock (timePicker) with material-ui?
- Unable to change my textfield value in material-ui with formik
- React boostrap carousel not working
- How to test for tooltip title in jest and testing/library
- Get the ID of a selected Card element and pass it to a modal to select the element
- React update component after loading data
- Component not rendering when using children as function
- How to redirect to other page with parameters in react
- React components not rendering when routing to new page with react-router-dom v6
- how to loop to expect a list of item in jest
- how to store value of 2 inputs dynamically generated in state at once
- React App converting JS to ES5 to target IE 11
- Custom SVG is not loading in my image tag
- React - show/hide element on click