Skip to content

Instantly share code, notes, and snippets.

@dwalkr
Created June 4, 2020 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwalkr/38f864fe0860be63d461968cba6ce9e7 to your computer and use it in GitHub Desktop.
Save dwalkr/38f864fe0860be63d461968cba6ce9e7 to your computer and use it in GitHub Desktop.
const [editMode] = useEditMode()
const { loadData } = useGithubFile({
path: 'src/navigation.json',
parse: JSON.parse,
serialize: JSON.stringify,
})
const [githubNavItems, setGithubNavItems] = useState(navigation)
useEffect(() => {
if (!editMode) return
loadData().then(setGithubNavItems)
}, [editMode])
const navItems = useMemo(() => {
if (editMode) {
return githubNavItems
}
return navigation
}, [editMode, navigation, githubNavItems])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment