xyflow / web

πŸ“– This monorepo contains the xyflow website and the documentation sites for React Flow and Svelte Flow.
https://xyflow.com
MIT License
43 stars 49 forks source link

Use createWithEqualityFn in mind-map-app-with-react-flow.mdx #372

Closed leochoo closed 5 months ago

leochoo commented 5 months ago

Reason for PR

TL;DR: Zustand warning @deprecated β€” Use createWithEqualityFn from 'zustand/traditional'

Details

When following this example in the tutorial, VSCode complains that this declaration using create is deprecated. Although the code works just fine, it recommends that we use createWithEqualityFn instead of create. It does solve the warning.

However, after some research, it seems that Zustand might deprecate this createWithEqualityFn...

It seems that they initially had quite some confusions among the users, which lead to v4.5.1 release fix, but still using the zustand@latest did not fix this warning for our case.

Very trivial issue, but wanted to bring up to see what React Flow team thinks about it.

Thank you for this awesome library.

My Versions: "reactflow": "^11.11.1", "zustand": "^4.5.2"

Screenshot

CleanShot 2024-04-18 at 10 18 45

Warning from VSCode

The signature '(selector: (state: RFState) => { nodes: Node[]; edges: Edge[]; onNodesChange: OnNodesChange; onEdgesChange: OnEdgesChange; }, equalityFn: (a: { ...; }, b: { ...; }) => boolean): { ...; }' of 'useRFStore' is deprecated.ts(6387)
react.d.mts(20, 8): The declaration was marked as deprecated here.
(alias) useRFStore<{
    nodes: Node[];
    edges: Edge[];
    onNodesChange: OnNodesChange;
    onEdgesChange: OnEdgesChange;
}>(selector: (state: RFState) => {
    nodes: Node[];
    edges: Edge[];
    onNodesChange: OnNodesChange;
    onEdgesChange: OnEdgesChange;
}, equalityFn: (a: {
    nodes: Node[];
    edges: Edge[];
    onNodesChange: OnNodesChange;
    onEdgesChange: OnEdgesChange;
}, b: {
    nodes: Node[];
    edges: Edge[];
    onNodesChange: OnNodesChange;
    onEdgesChange: OnEdgesChange;
}) => boolean): {
    nodes: Node[];
    edges: Edge[];
    onNodesChange: OnNodesChange;
    onEdgesChange: OnEdgesChange;
} (+2 overloads)
import useRFStore
@deprecated β€” Use createWithEqualityFn from 'zustand/traditional'
vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
reactflow-website βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 18, 2024 1:58am
svelteflow-website βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 18, 2024 1:58am
xyflow-svelte-examples βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 18, 2024 1:58am
xyflow-website βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Apr 18, 2024 1:58am
moklick commented 5 months ago

thanks!