I have a Class React component, that uses a functional Hook component if the browser pathName is /exp
When the page loads up, my app component changes is state about 3-4 times,
How can I prevent the Example hook from remounting if the prop has not changed ?
import React, { useState } from 'react';
function Example() {
console.log("i mounted")
}
__
export default class App extends Component {
state={key:"value"} <--------------------------------------MAIN APP STATE CHANGES 3 times
componentDidMount(){
//I change App state 3 times with conditional code
}
render() {
return (
<Router>
<Switch>
<Route path="/exp">
<Example prop="I have not changed" /> <-----------------PREVENT MULTIPLE MOUNTINGS
</Route>
</Switch>
</Router>
)
}