ListView selection executes twice, both badly
See original GitHub issueCategory
[ ] Enhancement
[X] Bug
[ ] Question
Version
1.0.0-beta.6
Expected / Desired Behavior / Question
I have a ListView component that is set like this:
<ListView
items={this.state.reactListItems}
compact={true}
viewFields={viewFields}
selectionMode={SelectionMode.single}
selection={ (e) => this.setState({
showPanel: true,
panelInfo: JSON.stringify(e)
})} />
In the selection area I have set a state update using local fat arrow to pass the this object, which I want to use in a panel (or modal or whatever).
My issue is that this code will execute twice; once where it passes the output from the selection but does not update the state, then again where it updates the state, but now it does not pass the selection.
So in the code above, the value is ultimately [] on this.state.panelInfo.
Observed Behavior
I expected the item value and the state update to execute once with the values passed from the selected item.
Steps to Reproduce
The code above should be sufficient to repro.
I also tried using this function for debugging:
public _getSelection(item: any, ctx: any) {
console.log('Selected items:', item);
ctx.setState({
showPanel: true,
panelInfo: JSON.stringify(item)
});
console.log(ctx.state);
}
Thanks for any suggestions on how to proceed!
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
It’s a closed thread.
Please, create new issue if you want us to pay attention to it.
Thank you!
Same issue on v2.4.0