fix(useReactFlow): use onNodesChange and onEdgesChange

This commit is contained in:
moklick
2022-03-15 18:38:58 +01:00
parent 514c15c0ef
commit 5b32746422
5 changed files with 107 additions and 36 deletions
+16 -18
View File
@@ -31,11 +31,9 @@ import Undirectional from './Undirectional';
import UpdatableEdge from './UpdatableEdge';
import UpdateNode from './UpdateNode';
import UseUpdateNodeInternals from './UseUpdateNodeInternals';
import UseZoomPanHelper from './UseZoomPanHelper';
import UseReactFlow from './UseReactFlow';
import Validation from './Validation';
const routes = [
{
path: '/',
@@ -146,8 +144,8 @@ const routes = [
component: UpdateNode,
},
{
path: '/usezoompanhelper',
component: UseZoomPanHelper,
path: '/usereactflow',
component: UseReactFlow,
},
{
path: '/useupdatenodeinternals',
@@ -169,18 +167,18 @@ const Header = () => {
const onChange = (event: ChangeEvent<HTMLSelectElement>) => navigate(event.target.value);
return (
<header>
<a className="logo" href="https://github.com/wbkd/react-flow">
React Flow Dev
</a>
<select defaultValue={location.pathname} onChange={onChange}>
{routes.map((route) => (
<option value={route.path} key={route.path}>
{route.path === '/' ? 'overview' : route.path.substring(1, route.path.length)}
</option>
))}
</select>
</header>
<header>
<a className="logo" href="https://github.com/wbkd/react-flow">
React Flow Dev
</a>
<select defaultValue={location.pathname} onChange={onChange}>
{routes.map((route) => (
<option value={route.path} key={route.path}>
{route.path === '/' ? 'overview' : route.path.substring(1, route.path.length)}
</option>
))}
</select>
</header>
);
};
@@ -189,7 +187,7 @@ ReactDOM.render(
<Header />
<Routes>
{routes.map((route) => (
<Route path={route.path} key={route.path} element={<route.component />}/>
<Route path={route.path} key={route.path} element={<route.component />} />
))}
</Routes>
</BrowserRouter>,