Created
April 29, 2020 13:27
-
-
Save hswolff/ec231e24696e66defccf49f15b77d544 to your computer and use it in GitHub Desktop.
Revisions
-
hswolff created this gist
Apr 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ function useLazyAnalytics() { const [value, setValue] = useState(() => { return () => { const raceError = new Error('handler called before loaded'); bugsnagClient.notify(raceError); }; }); useEffect(() => { import('./lazyAnalytics').then((mod) => { setValue(() => mod.default); }); }, []); return value; } // usage const trackMongoNavAnalytics = useTrackMongoNavAnalytics();