-
-
Save dwalkr/38f864fe0860be63d461968cba6ce9e7 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
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