Uncaught Error: useBlocker must be used within a data router
JaLe29 opened this issue · comments
JaLe 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",
github-actions commented
Hey, @JaLe29. Thank you so much for taking the time to point this out
JaLe commented
Abdul Haseeb commented
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: