Skip to content

Commit

Permalink
Merge branch 'fix-docs-typo' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
prevwong committed Jan 17, 2020
2 parents 3a9ee47 + cf01dce commit d2a869a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion packages/docs/docs/api/useEditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
Expand Down Expand Up @@ -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 (
<a
onClick={_ => {
setProp(selectedNodeId, props => {
props.text = "new value";
});
}}
>
Update
</a>
)
}
```

### Hiding and Deleting a Node
```jsx
const Example = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d2a869a

Please sign in to comment.