Created
June 4, 2020 16:23
-
-
Save dwalkr/0456a0aee8e2dfa715642a3f5995a71a to your computer and use it in GitHub Desktop.
This file contains 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 characters
useEffect(() => { | |
setHasError(false) | |
if (!editMode) { | |
import(`../content/${slug}.json`) | |
.then((content) => { | |
setContent(content.default) | |
}) | |
.catch((e) => { | |
setHasError(true) | |
}) | |
} else { | |
// TODO now we're loading this data 2x when in edit mode | |
loadData().then((result) => { | |
if (result && result.error) { | |
setHasError(true) | |
} | |
}) | |
} | |
}, [slug, setContent, setHasError, editMode]) | |
if (hasError) { | |
return <NotFound /> | |
} | |
//... return page component |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment