Skip to content

Some kind of onbeforeunload for routes? #22

@mattmccray

Description

@mattmccray

Perhaps I'm missing something, but is there a way to register a callback for route changes... And cancel them? Like an onbeforeunload but for routes?

function TestScreen(props) {
  const route = useRoute()

  route.beforeTransition(e => { // maybe 'e' contains target route info?
    // (user code to check for form changes...)
   return false // false to prevent transition?
  })

  return (
    <form> . . . </form>
  )
}

I don't know about the api specifically, that's just as an example of potential usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions