fix(dev): fix scroll to top on app first load

This commit is contained in:
Sahil H. Mobaidin 2021-11-10 23:32:01 +02:00
parent 69576610c4
commit ade416ff1b
2 changed files with 10 additions and 3 deletions

View file

@ -7,6 +7,10 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.4 - 2021-11-10
- fix: fix scroll to top on app first load
## 0.6.3 - 2021-11-10
- fix: add trailing slash to user components glob

View file

@ -9,13 +9,16 @@ import {useServerState} from '../useServerState';
* server state, which in turn fetches the correct server component.
*/
export function ServerStateRouter() {
const {setServerState, pending} = useServerState() as ServerStateContextValue;
const {setServerState, pending, serverState} =
useServerState() as ServerStateContextValue;
const [isNavigating, setIsNavigating] = useState(false);
const location = useLocation();
useEffect(() => {
setIsNavigating(true);
setServerState('pathname', location.pathname);
if (serverState.pathname !== location.pathname) {
setIsNavigating(true);
setServerState('pathname', location.pathname);
}
}, [location.pathname, setServerState]);
useEffect(() => {