in my code when i click button, component Aaaaa
is not re-rendered, but when i tap on link, component Aaaaa
is re-rendered. i can't find cause of it?
function App() {
return (
<>
<button onClick={() => window.history.pushState('','','/about')}>About</button>
<Link to='/about'>to About</Link>
<Aaaaaa/>
</>
);
}
and:
Aaaaaa(){
const location = useLocation()
return <div>About </div>
}
window.history.pushState
is not from react-router. Take a look at the docs for the react-router version of that herewindow.history.pushState
cause not rerender componentAaaaa
? whilewindow.history.pushState
change location andAaaaa
useuseLocation()
hook.