wwf
3 天以前 a430284aa21e3ae1f0d5654e55b2ad2852519cc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { useStoreApi } from 'reactflow'
 
const useNodeInfo = (nodeId: string) => {
  const store = useStoreApi()
  const {
    getNodes,
  } = store.getState()
  const allNodes = getNodes()
  const node = allNodes.find(n => n.id === nodeId)
  const isInIteration = !!node?.data.isInIteration
  const parentNodeId = node?.parentId
  const parentNode = allNodes.find(n => n.id === parentNodeId)
  return {
    node,
    isInIteration,
    parentNode,
  }
}
 
export default useNodeInfo