From 662a6297e7c71de5705668cdbd2f8eb6f671312e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Jan 2018 21:06:35 +0000 Subject: [PATCH] FilteredList, now being a controlled component does not need state Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/DevtoolsDialog.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index e7f66bc0c4..3ce1dfe7d4 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -252,24 +252,15 @@ class FilteredList extends React.Component { constructor(props, context) { super(props, context); this.onQuery = this.onQuery.bind(this); - - this.state = { - query: this.props.query, - }; - } - - componentWillReceiveProps(nextProps) { - if (this.state.query !== nextProps.query) this.setState({ query: nextProps.query }); } onQuery(ev) { - this.setState({ query: ev.target.value }); if (this.props.onChange) this.props.onChange(ev.target.value); } filterChildren() { - if (this.state.query) { - const lowerQuery = this.state.query.toLowerCase(); + if (this.props.query) { + const lowerQuery = this.props.query.toLowerCase(); return this.props.children.filter((child) => child.key.toLowerCase().includes(lowerQuery)); } return this.props.children; @@ -279,7 +270,7 @@ class FilteredList extends React.Component { return
{ this.filterChildren() }