chore(useNodesData): cleanup return type
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import { memo } from 'react';
|
||||
import { Handle, Position, useHandleConnections, useNodesData } from '@xyflow/react';
|
||||
import { TextNode, isTextNode, type MyNode } from '.';
|
||||
import { isTextNode, type MyNode } from '.';
|
||||
|
||||
function ResultNode() {
|
||||
const connections = useHandleConnections({
|
||||
type: 'target',
|
||||
});
|
||||
const nodesData = useNodesData<MyNode>(connections.map((connection) => connection.source));
|
||||
const textNodes = nodesData.filter(isTextNode) as TextNode[];
|
||||
|
||||
textNodes[0].data;
|
||||
const textNodes = nodesData.filter(isTextNode);
|
||||
|
||||
return (
|
||||
<div style={{ background: '#eee', color: '#222', padding: 10, fontSize: 12, borderRadius: 10 }}>
|
||||
|
||||
@@ -20,8 +20,8 @@ export type ResultNode = Node<{}, 'result'>;
|
||||
export type UppercaseNode = Node<{ text: string }, 'uppercase'>;
|
||||
export type MyNode = TextNode | ResultNode | UppercaseNode;
|
||||
|
||||
export function isTextNode(node: any): node is TextNode | UppercaseNode {
|
||||
return node.type === 'text' || node.type === 'uppercase';
|
||||
export function isTextNode(node: any): node is TextNode {
|
||||
return node.type === 'text';
|
||||
}
|
||||
|
||||
const nodeTypes = {
|
||||
|
||||
Reference in New Issue
Block a user