0

When I use <React.StrictMode> in

ReactDOM.render(<React.StrictMode><App /></React.StrictMode>, document.getElementById('root'));

and the App.js is

render() {
  console.log('enter render')
return(<React.Fragment>
                <h1>HI</h1>
    </React.Fragment>
)}}

after run project console show

enter render

2 times

if I delete <React.StrictMode> then I saw in the consol

enter render

for one time

why did this happen?

  • please check the duplicate post – Shubham Khatri May 20 '20 at 08:49
  • For some internal reason probably only the React core developers know, and it honestly doesn't _matter_. React can decide to call your `render()` function in the middle of the night, and it shouldn't matter, since `render()` should be a pure function that just returns markup. – AKX May 20 '20 at 08:50

0 Answers0