Skip to content

Commit 662a629

Browse files
committed
FilteredList, now being a controlled component does not need state
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 04bca93 commit 662a629

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

‎src/components/views/dialogs/DevtoolsDialog.js‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,15 @@ class FilteredList extends React.Component {
252252
constructor(props, context) {
253253
super(props, context);
254254
this.onQuery = this.onQuery.bind(this);
255-
256-
this.state = {
257-
query: this.props.query,
258-
};
259-
}
260-
261-
componentWillReceiveProps(nextProps) {
262-
if (this.state.query !== nextProps.query) this.setState({ query: nextProps.query });
263255
}
264256

265257
onQuery(ev) {
266-
this.setState({ query: ev.target.value });
267258
if (this.props.onChange) this.props.onChange(ev.target.value);
268259
}
269260

270261
filterChildren() {
271-
if (this.state.query) {
272-
const lowerQuery = this.state.query.toLowerCase();
262+
if (this.props.query) {
263+
const lowerQuery = this.props.query.toLowerCase();
273264
return this.props.children.filter((child) => child.key.toLowerCase().includes(lowerQuery));
274265
}
275266
return this.props.children;
@@ -279,7 +270,7 @@ class FilteredList extends React.Component {
279270
return <div>
280271
<input size="64"
281272
onChange={this.onQuery}
282-
value={this.state.query}
273+
value={this.props.query}
283274
placeholder={_t('Filter results')}
284275
className="mx_TextInputDialog_input mx_DevTools_RoomStateExplorer_query" />
285276
{ this.filterChildren() }

0 commit comments

Comments
 (0)