Added translator cleanup on logo click (#11)

This commit is contained in:
David
2021-04-08 22:28:45 +02:00
committed by GitHub
parent ea8c1bad57
commit a80c177440
3 changed files with 19 additions and 7 deletions

View File

@@ -56,7 +56,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, transl
}, [source, target, delayedQuery, initial, home, isLoading]);
useEffect(() => {
const handler = () => dispatch({ type: Actions.SET_FIELD, payload: { key: "isLoading", value: true }});
const handler = (url: string) => url === Router.asPath || dispatch({ type: Actions.SET_FIELD, payload: { key: "isLoading", value: true }});
Router.events.on("beforeHistoryChange", handler);
return () => Router.events.off("beforeHistoryChange", handler);
}, []);