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

Breaking at React router DOM

SatyaQworks opened this issue · comments

: navigator.block is not a function at use-blocker.ts:13:1

react-router-dom: v6.4.1

this will not work with react-router v6.4x because they removed the APIs necessary for this solution to work in v6.4.0. There is a pretty lengthy thread about this here.

that still works with
remix-run/react-router#8139 (comment)
and

import { FC } from "react";
import { unstable_HistoryRouter as HistoryRouter } from "react-router-dom";
import { history } from "history";


const App: FC = () => {
  return (
    <HistoryRouter history={history}>
      <YOUR CODE HERE>
    </HistoryRouter>
  );
};

export default App;

I will check this issue this weekend

remix-run/react-router#8139 (comment)

Will wait for usePrompt and useBlocker to come back in the next release.

FYI: useBlocker is now available in React Router 👏

@karol-majewski thanks for heads-up, will create an update.

Updated with react-router-prompt v0.5.0.

Note: This supports react router dom >=v6.7.0 and supports only data routers
Do reopen if you find any issue in the release