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.pushStateis not from react-router. Take a look at the docs for the react-router version of that herewindow.history.pushStatecause not rerender componentAaaaa? whilewindow.history.pushStatechange location andAaaaauseuseLocation()hook.