Skip to content

Commit 401255e

Browse files
Tree: Use cloned nodes in Stories
This prevents data reference leaking between stories
1 parent 89796f1 commit 401255e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/tree/__docs__/storybook-stories.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React from 'react';
22
import createReactClass from 'create-react-class';
33
import PropTypes from 'prop-types';
44
import { storiesOf, action } from '@storybook/react';
5+
import cloneDeep from 'lodash.clonedeep';
56
import IconSettings from '../../icon-settings';
67

78
import { TREE } from '../../../utilities/constants';
89
import sampleNodes from '../../../utilities/sample-data/tree';
910

11+
1012
import Tree from '../../tree';
1113
import Search from '../../forms/input/search';
1214

@@ -38,7 +40,7 @@ const DemoTree = createReactClass({
3840
? sampleNodes[this.props.exampleNodesIndex]
3941
: sampleNodes.sampleNodesDefault;
4042
return {
41-
nodes: initalNodes,
43+
nodes: cloneDeep(initalNodes),
4244
selectedNode: undefined,
4345
searchTerm: this.props.searchable ? 'fruit' : undefined,
4446
};

0 commit comments

Comments
 (0)