chore(examples): add cancel connection

This commit is contained in:
moklick
2022-10-08 17:11:40 +02:00
parent b005b682c9
commit 4aa742f6f2
+8 -10
View File
@@ -54,6 +54,11 @@ const routes: IRoute[] = [
path: '/backgrounds',
component: Backgrounds,
},
{
name: 'Cancel Connection',
path: '/cancel-connection',
component: CancelConnection,
},
{
name: 'Controlled/Uncontrolled',
path: '/controlled-uncontrolled',
@@ -214,21 +219,17 @@ const routes: IRoute[] = [
path: '/use-key-press',
component: UseKeyPress,
},
{
path: '/cancel-connection',
component: CancelConnection
}
];
const Header = () => {
const location = useLocation();
const navigate = useNavigate();
const [currentPath, setCurrentPath] = useState(location.pathname);
useEffect(() => {
const name = routes.find((route) => route.path === currentPath)?.name;
document.title = `React Flow Examples${name ? ' - ' + name : ''}`;
navigate(currentPath)
navigate(currentPath);
}, [currentPath]);
return (
@@ -236,10 +237,7 @@ const Header = () => {
<a className="logo" href="https://github.com/wbkd/react-flow">
React Flow Dev
</a>
<select
value={currentPath}
onChange={(event) => setCurrentPath(event.target.value)}
>
<select value={currentPath} onChange={(event) => setCurrentPath(event.target.value)}>
{routes.map((route) => (
<option value={route.path} key={route.path}>
{route.name}