I created a react (version 18) application with next.js with typescript it was working fine when running the application npm run dev working fine, but after installing the react flow npm install reactflow and try to use the code like below the error is happening. Please help me to fix this issue.
import ReactFlow, { Controls, Background } from 'reactflow';
import 'reactflow/dist/style.css';
const edges = [{ id: '1-2', source: '1', target: '2' }];
const nodes = [
{
id: '1',
data: { label: 'Hello' },
position: { x: 0, y: 0 },
type: 'input',
},
{
id: '2',
data: { label: 'World' },
position: { x: 100, y: 100 },
},
];
function Flow() {
return (
<div style={{ height: '100%' }}>
<ReactFlow nodes={nodes} edges={edges}>
<Background />
<Controls />
</ReactFlow>
</div>
);
}
export default Flow;
page.tsx
import Flow from './components/canvas';
export default function Home() {
return (
<main className='flex min-h-screen flex-col items-center justify-between p-24'>
<h1>Testing head</h1>
<Flow />
</main>
);
}
Package.json
{
"name": "demo-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "14.0.3",
"react": "^18",
"react-dom": "^18",
"reactflow": "^11.10.1"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.3",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}

