bridge: only use window.ethereum if it exists
Otherwise we end up crashing on pageload. It likely doesn't exist if the
user does not have Metamask or a similar extension installed.
commitaf3a63a385ea1cddbc8615b032fc5f2e4fdd15af
authorfang <git@fang.io>
dateTue 30 Mar 2021, 18:04 (6 years ago)
parenta74bc16
src/Bridge.js+5−3
@@ -70,9 +70,11 @@ function Bridge() {
7070 // full reload if the user changes their selected network in Metamask
7171 //
7272 useEffect(() => {
73− window.ethereum.on('chainChanged', () => {
74− document.location.reload();
75− });
73+ if (window.ethereum) {
74+ window.ethereum.on('chainChanged', () => {
75+ document.location.reload();
76+ });
77+ }
7678 }, []);
7779
7880 return (