the returned story will always be the
first originalStory use in useState(originalStory) ?
initialState is never overwritten.
export function useStoryblok(originalStory, preview, locale) {
const [story, setStory] = useState(originalStory)
and the state is only changed if we are in preview mode as initEventListeners runs setStory
useEffect(() => {
// only load inside preview mode
if (preview) {
// first load the bridge, then initialize the event listeners
addBridge(initEventListeners)
}
}, [])
if (data.story) {
setStory(data.story)
}
add a useEffect to update story to originalStory?
useEffect(() => {
setStory(originalStory)
}, [originalStory])
the returned story will always be the
first originalStory use in
useState(originalStory)?initialState is never overwritten.
and the state is only changed if we are in preview mode as initEventListeners runs setStory
add a useEffect to update story to originalStory?