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