React-sortable-tree: Utils Examples Need Improvement

Created on 1 Dec 2017  路  4Comments  路  Source: frontend-collective/react-sortable-tree

The provided examples do not use react-sortable-tree as an npm package. Instead, they reference the src folder:
import SortableTreeWithoutDndContext as Sortable, {toggleExpandedForAll,} from '../../src/index';

This does not work when using the npm package:

import SortableTreeWithoutDndContext as Sortable, {toggleExpandedForAll,} from 'react-sortable-tree';

I can not figure out how to import the functions exported by tree-data-utils.js.

Please provide examples that import react-sortable-tree rather than src so we can see how it is done.

Thank you!

Most helpful comment

Yes, your example worked for me:

import SortableTree, { toggleExpandedForAll } from "react-sortable-tree";

Thank you!

All 4 comments

@mcolburn while the source folder do reference the src folder you are not even correctly following the example at all.... instead of this
import SortableTreeWithoutDndContext as Sortable, {toggleExpandedForAll,} from '../../src/index';

this should be the correct way of using function from tree-data-utils.js

import {SortableTreeWithoutDndContext as Sortable, toggleExpandedForAll} from '../../src/index';

let me know if this doesn't work for you

What I am asking for is an example from the perspective of someone who has pulled from npm, not someone who cloned or forked the github repo. If someone has pulled react-sortable-tree from npm, there is no react-sortable-tree src to refer to.

This does not work:

import {SortableTreeWithoutDndContext as Sortable, toggleExpandedForAll} from 'react-sortable-tree';

The only solution I have found so far is to copy the tree-data-utils.js file into my own development src folder and use it from there.

@mcolburn Hi, I believe this example is what you want. Can you try it?

Yes, your example worked for me:

import SortableTree, { toggleExpandedForAll } from "react-sortable-tree";

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LogicMonsters picture LogicMonsters  路  5Comments

xmhscratch picture xmhscratch  路  5Comments

JonatanGarciaClavo picture JonatanGarciaClavo  路  3Comments

theonelucas picture theonelucas  路  3Comments

mhiggs picture mhiggs  路  3Comments