Skip to content

Commit

Permalink
docs: ✏️ made large collection example use UnstableTree
Browse files Browse the repository at this point in the history
  • Loading branch information
diogofcunha committed Jan 27, 2019
1 parent f2fc147 commit 7c0b6ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions demo/src/examples/LargeCollection.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, {Component} from 'react';

import Tree from '../../../src/TreeContainer';
import UnstableFastTree from '../../../src/UnstableFastTree';
import Renderers from '../../../src/renderers';
import {createEntry, constructTree} from '../toolbelt';
import TreeState from '../../../src/state/TreeState';

const MIN_NUMBER_OF_PARENTS = 500;
const MAX_NUMBER_OF_CHILDREN = 15;
const MAX_NUMBER_OF_CHILDREN = 30;
const MAX_DEEPNESS = 4;

const {Deletable, Expandable, Favorite} = Renderers;
Expand All @@ -19,7 +20,7 @@ const totalNumberOfNodes = getTotalNumberOfElements(Nodes);

class LargeCollection extends Component {
state = {
nodes: Nodes,
nodes: TreeState.createFromTree(Nodes),
};

handleChange = nodes => {
Expand All @@ -28,7 +29,7 @@ class LargeCollection extends Component {

render() {
return (
<Tree nodes={this.state.nodes} onChange={this.handleChange}>
<UnstableFastTree nodes={this.state.nodes} onChange={this.handleChange}>
{({style, node, ...rest}) => (
<div style={style}>
<Expandable node={node} {...rest}>
Expand All @@ -39,7 +40,7 @@ class LargeCollection extends Component {
</Expandable>
</div>
)}
</Tree>
</UnstableFastTree>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/toolbelt.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const createEntry = (key, fileName, name, description, component) => ({
let ids = {};

const getUniqueId = () => {
const candidateId = Math.round(Math.random() * 1000000);
const candidateId = Math.round(Math.random() * 1000000000);

if (ids[candidateId]) {
return getUniqueId();
Expand Down

0 comments on commit 7c0b6ed

Please sign in to comment.