on master help sign in
bridge: reload when selected chain changes
2399474fang
src/Bridge.js+9
@@ -1,4 +1,5 @@
1import React from 'react';
1import React from 'react';
2+import { useEffect } from 'react';
2import { hot } from 'react-hot-loader/root';
3import { hot } from 'react-hot-loader/root';
3import { Just, Nothing } from 'folktale/maybe';
4import { Just, Nothing } from 'folktale/maybe';
4import { IndigoApp } from 'indigo-react';
5import { IndigoApp } from 'indigo-react';
@@ -66,6 +67,14 @@ function useInitialRoutes() {
66function Bridge() {
67function Bridge() {
67 const initialRoutes = useInitialRoutes();
68 const initialRoutes = useInitialRoutes();
68
69
70+ // full reload if the user changes their selected network in Metamask
71+ //
72+ useEffect(() => {
73+ window.ethereum.on('chainChanged', () => {
74+ document.location.reload();
75+ });
76+ }, []);
77+
69 return (
78 return (
70 <WithErrorBoundary render={error => <GlobalErrorBoundary error={error} />}>
79 <WithErrorBoundary render={error => <GlobalErrorBoundary error={error} />}>
71 <Provider
80 <Provider