From 9c877a621efcdc36b3620acb02c2f70689c8463e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Tue, 13 Feb 2018 06:13:27 -0800 Subject: [PATCH] fix inserting/deleting children Summary: Inserting or deleting nodes threw an error, due to some changes I made earlier. This fixes the error. Reviewed By: emilsjolander Differential Revision: D6975950 fbshipit-source-id: d04df08260ab8ab248726809329e69f4d264decd --- website/src/components/Playground/index.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/website/src/components/Playground/index.js b/website/src/components/Playground/index.js index be069448..0d5dec09 100644 --- a/website/src/components/Playground/index.js +++ b/website/src/components/Playground/index.js @@ -146,9 +146,8 @@ export default class Playground extends Component { const {selectedNodePath, layoutDefinition} = this.state; if (selectedNodePath) { const index = selectedNodePath.pop(); - const updatedChildren = layoutDefinition - .getIn(getPath(selectedNodePath)) - .delete(index); + const path = getPath(selectedNodePath).concat('children'); + const updatedChildren = layoutDefinition.getIn(path).delete(index); this.modifyAtPath(path, updatedChildren); this.setState({selectedNodePath: null}); } @@ -157,9 +156,8 @@ export default class Playground extends Component { onAdd = () => { const {selectedNodePath, layoutDefinition} = this.state; if (selectedNodePath) { - const updatedChildren = layoutDefinition - .getIn(getPath(selectedNodePath)) - .push(LayoutRecord()); + const path = getPath(selectedNodePath).concat('children'); + const updatedChildren = layoutDefinition.getIn(path).push(LayoutRecord()); this.modifyAtPath( path, updatedChildren, @@ -173,7 +171,6 @@ export default class Playground extends Component { value: any, selectedNodePath?: ?Array = this.state.selectedNodePath, ) { - console.log(setIn); // $FlowFixMe const layoutDefinition = setIn(this.state.layoutDefinition, path, value); this.setState({