Skip to content

only changing state if in enterEditmode #17

@chrillep

Description

@chrillep

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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions