GithubHelp home page GithubHelp logo

Comments (5)

bkniffler avatar bkniffler commented on June 26, 2024

It makes sense for your core module. But you should really consider to outsource the toggle functionality to your decorator and join together header/toggle, as this would easily allow us to customize the behavior.

from react-treebeard.

alexcurtis avatar alexcurtis commented on June 26, 2024

Maybe a good step in the right direction is for treebeard to determine this and pass it as a prop to the decorators. Then we can look at the decorators as a separate issue. What I'm trying to achieve here is simplifying down the data input as much as possible, so getting Treebeard setup is a snap for people in general. At the moment, the data bit feels a little contrived.

from react-treebeard.

bkniffler avatar bkniffler commented on June 26, 2024

Separate those properties, that you need for core functionality (children, toggled) and those additional for default out-of-the-box behavior (name, active, ...). Allow for a custom .id property used as a key instead of 'index' for building the tree. Allow for renaming core properties by this occasion, like items instead of children.

Don't forget that there will always be the users who want their tree state managed by treebeard and those who want to manage it themselves, which currently works okay if you suppress the default onToggle with e.preventDefault(), so there is no setState({toggled: true}).

from react-treebeard.

bkniffler avatar bkniffler commented on June 26, 2024

Also it would be great to use something like http://jnuno.com/tree-model-js/ to store the tree data, but a node will have its toggled inside of a property model in that case. So maybe you could allow overwriting the toggled by a function passed as a prop like:

function isToggled(node){
   return node.model.toggled;
}
<TreeBeard isToggled={isToggled}/>

from react-treebeard.

alexcurtis avatar alexcurtis commented on June 26, 2024

I'll add in the id -> key option as I think that is definitely a good idea. We have to make sure we aren't making it over complicated with some of these things.

from react-treebeard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.