antvis / antvis/Graphin

Graphin doesn't work with global state library Jotai

Open
#449 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.1k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Using global state library such as Jotai or Zustend causes the following error:

> *TypeError: Cannot read properties of undefined (reading 'manipulateBehaviors')*

However, using `useState` works as expected.

```javascript
const [layout] = useAtom(layoutAtom);
// versus
const [layout] = useState("graphin-force");
```

Full code below:

```javascript
import Graphin, { Utils, Behaviors } from "@antv/graphin";
import { atom, useAtom } from "jotai";
import "./styles.css";

const { ZoomCanvas } = Behaviors;

const data = Utils.mock(10).circle().graphin();
const layoutAtom = atom("graphin-force");

export default function App() {
const [layout] = useAtom(layoutAtom);
// const [layout] = useState("graphin-force");

return (






);
}

```

### Your Example Website or App

https://codesandbox.io/s/graphin-jotai-g2n4je?file=/src/App.tsx

### Expected behavior

Graphin should work with Jotai

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.