import React, { useState } from "react";import {BrowserRouter as Router, Switch, Route, Link, Prompt} from "react-router-dom";export default function PreventingTransitionsExample() { return ( } /> One} /> Two} /> );}function BlockingForm() { let [isBlocking, setIsBlocking] = useState(false); return (
{ event.preventDefault(); event.target.reset(); setIsBlocking(false);}} > `Are you sure you want to go to ${location.pathname}`} />

Blocking?{" "} {isBlocking ? "Yes, click a link or the back button" : "Nope"}

{setIsBlocking(event.target.value.length > 0);}} />

);}