Skip to content

Commit 9b91aae

Browse files
committed
Do not reset selected item in ListBox
By some funny reason we are unable to select new item in the ListBox. I have no idea why it worked before but apparently there were a problem in state management logic. Despite having plans to rewrite things in ListBox to make it simpler and even more general, let's fix the logic now in order to properly manage currently selected syntax. In few words, the issue is that React components have asynchronus state and apparently by the time 'componentWillReceiveProps' is called the state is not updated. So we should not reset the state in this case.
1 parent 73f427f commit 9b91aae

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/components/ListBox.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ class ListBox extends React.Component {
2525
if (!selected) return;
2626
selected = selected.value;
2727
nextProps.onClick(selected);
28+
this.setState({ selected });
2829
}
29-
30-
this.setState({ selected });
3130
}
3231

3332
onClick(e) {

0 commit comments

Comments
 (0)