fix(dev): fix scroll to top on app first load
This commit is contained in:
parent
69576610c4
commit
ade416ff1b
|
@ -7,6 +7,10 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
<!-- ## Unreleased -->
|
<!-- ## Unreleased -->
|
||||||
|
|
||||||
|
## 0.6.4 - 2021-11-10
|
||||||
|
|
||||||
|
- fix: fix scroll to top on app first load
|
||||||
|
|
||||||
## 0.6.3 - 2021-11-10
|
## 0.6.3 - 2021-11-10
|
||||||
|
|
||||||
- fix: add trailing slash to user components glob
|
- fix: add trailing slash to user components glob
|
||||||
|
|
|
@ -9,13 +9,16 @@ import {useServerState} from '../useServerState';
|
||||||
* server state, which in turn fetches the correct server component.
|
* server state, which in turn fetches the correct server component.
|
||||||
*/
|
*/
|
||||||
export function ServerStateRouter() {
|
export function ServerStateRouter() {
|
||||||
const {setServerState, pending} = useServerState() as ServerStateContextValue;
|
const {setServerState, pending, serverState} =
|
||||||
|
useServerState() as ServerStateContextValue;
|
||||||
const [isNavigating, setIsNavigating] = useState(false);
|
const [isNavigating, setIsNavigating] = useState(false);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsNavigating(true);
|
if (serverState.pathname !== location.pathname) {
|
||||||
setServerState('pathname', location.pathname);
|
setIsNavigating(true);
|
||||||
|
setServerState('pathname', location.pathname);
|
||||||
|
}
|
||||||
}, [location.pathname, setServerState]);
|
}, [location.pathname, setServerState]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Reference in a new issue