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
This commit is contained in:
committed by
Facebook Github Bot
parent
a3144150e0
commit
9c877a621e
@@ -146,9 +146,8 @@ export default class Playground extends Component<Props, State> {
|
||||
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<Props, State> {
|
||||
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<Props, State> {
|
||||
value: any,
|
||||
selectedNodePath?: ?Array<number> = this.state.selectedNodePath,
|
||||
) {
|
||||
console.log(setIn);
|
||||
// $FlowFixMe
|
||||
const layoutDefinition = setIn(this.state.layoutDefinition, path, value);
|
||||
this.setState({
|
||||
|
Reference in New Issue
Block a user