Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the difference between setProp in useNode and useEditor hooks? #573

Open
emewjin opened this issue Nov 2, 2023 · 1 comment
Open

Comments

@emewjin
Copy link

emewjin commented Nov 2, 2023

The useNode and useEditor hooks both provide the actions.setProp. The documentation provides descriptions for each method as shown below, but I'm not entirely clear on the differences.
What is the difference between setProp in useNode and useEditor hooks?
The way they are used may vary slightly, but their ultimate function is the same?

const {
    // Docs: Manipulate the props of the given Node. 
    // type: (nodeId: NodeId, update: (props: Object) => void) => void
    actions: { setProp },
  } = useEditor();

const {
    // Docs: Manipulate the current component's props. Additionally, specify a throttleRate to throttle the changes recoded in history for undo/redo
    // type: (props: Object, throttleRate?: number) => void
    actions: { setProp },
  } = useNode();
@brerdem
Copy link

brerdem commented Dec 14, 2023

Only thing is setProp from Editor accepts an ID so you can change any prop of any node. The other one is node's setProp function. You can only change current node's props

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants