diff --git a/packages/docs/docs/api/useEditor.md b/packages/docs/docs/api/useEditor.md index 609c612af..1e6d7aebb 100644 --- a/packages/docs/docs/api/useEditor.md +++ b/packages/docs/docs/api/useEditor.md @@ -39,7 +39,7 @@ const { connectors, actions, query, ...collected } = useEditor(collector); ["delete", "(nodeID: NodeId) => void", "Delete the specified Node"], ["deserialize", "() => String", "Recreate Nodes from JSON. This will clear all the current Nodes in the editor state with the recreated Nodes"], ["move", "(nodeId: NodeId, targetParentId: NodeId, index: number) => void", "Move a Node to the specified parent Node at the given index."], - ["setProp", "(nodeId: NodeId, props: Object) => void", "Manipulate the props of the given Node"], + ["setProp", "(nodeId: NodeId, update: (props: Object) => void) => void", "Manipulate the props of the given Node"], ["setHidden", "(nodeId: NodeId, bool: boolean) => void", "When set to true, the User Component of the specified Node will be hidden, but not removed"], ["setCustom", "(nodeId: NodeId, custom: (custom: Object) => void", "Update the given Node's custom properties"], ["setOptions", "(options: Object) => void", "Update the editor's options. The options object passed is the same as the <Editor /> props."] @@ -79,6 +79,29 @@ const Example = () => { } ``` +### Updating props +```tsx +import {useEditor} from "@craftjs/core"; + +const Example = () => { + const { selectedNodeId, actions: {setProp} } = useEditor((state) => ({ + selectedNodeId: state.events.selected + })); + + return ( + { + setProp(selectedNodeId, props => { + props.text = "new value"; + }); + }} + > + Update + + ) +} +``` + ### Hiding and Deleting a Node ```jsx const Example = () => { diff --git a/packages/docs/package.json b/packages/docs/package.json index fec024c38..fe43fd04a 100755 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -3,7 +3,7 @@ "version": "0.1.0-beta.1", "private": true, "scripts": { - "start-docs": "docusaurus start", + "start": "docusaurus start", "build": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy"