sshyam-gupta / react-router-prompt

A replacement component for the react-router 6 `Prompt`. Allows for more flexible dialogs.

Home Page:https://codesandbox.io/s/react-router-prompt-example-react-router-6-7-y9ug7z?file=/src/App.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught Error: useBlocker must be used within a data router

JaLe29 opened this issue · comments

commented

I am getting an error just with your example code

Error

Uncaught Error: useBlocker must be used within a data router

Code:

<ReactRouterPrompt when>
  {({ isActive, onConfirm, onCancel }) => (
    <Modal show={isActive}>
      <div>
        <p>Do you really want to leave?</p>
        <button onClick={onCancel}>Cancel</button>
        <button onClick={onConfirm}>Ok</button>
      </div>
    </Modal>
  )}
</ReactRouterPrompt>

Libs:

    "react-router-dom": "^6.14.2",
    "react-router-prompt": "^0.5.4",

Hey, @JaLe29. Thank you so much for taking the time to point this out

hi @JaLe29 i am still getting similar error i am using
"react-router-dom": "^6.10.0", "react-router-prompt": "^0.5.4",
i am configuring routes like this:
image