Closed
Description
Would make data direction much clearer. Currently the component hinges on working against object references passed as props.
So, something like this;
<CheckboxTree
nodes={this.state.nodes}
checked={this.state.checked}
collapsed={this.state.collapsed}
onCollapse={this.onCollapse}
onCheck={this.onCheck} />
where
onCollapse(item) {
// return // uncommenting would disable collapsing functionality entirely
this.setState({
collapsed: [item, ...this.state.collapsed]
})
}
onCheck(item) {
this.setState({
checked: [item, ...this.state.checked]
})
}
Had some issues figuring this component out, took quite some time to debug an issue I had with breaking object references (see #10). I think this is the more idiomatic way of doing reusable components.
@jakezatecky Thoughts? Would you have time to do such a refactor should you agree?
Metadata
Metadata
Assignees
Projects
Relationships
Development
No branches or pull requests
Activity
jakezatecky commentedon Oct 10, 2016
I definitely agree that this should be made stateless and I agree that the data flow is sometimes...unclear. This is something that I was intending to work on. I have some available toward the end of this week so I will slate some time for this and other changes around there.
williamboman commentedon Oct 10, 2016
That would be absolutely awesome. I don't have time to work on this, but holla at me if you need help with anything.
Make component purely stateless
jakezatecky commentedon Oct 14, 2016
I was a bit on a time-crunch for some other work, but the component is now stateless. Needs to be cleaned up a bit before being merged into master. Will finish it up within the week.
checked
propertywilliamboman commentedon Nov 10, 2016
It still mutates the
checked
andexpanded
props, doesn't it? I'm running the feature branch but still getting unexpected behavior. Bypassing it by;Do not mutate properties