diff --git a/src/components/utils/article-search.tsx b/src/components/utils/article-search.tsx index 26a6d3a..fac0e98 100644 --- a/src/components/utils/article-search.tsx +++ b/src/components/utils/article-search.tsx @@ -12,7 +12,11 @@ type SearchProps = { dispatch: AppDispatch } -class ArticleSearch extends React.Component { +type SearchState = { + query: string +} + +class ArticleSearch extends React.Component { debouncedSearch: (query: string) => void inputRef: React.RefObject @@ -27,10 +31,12 @@ class ArticleSearch extends React.Component { } }, 750) this.inputRef = React.createRef() + this.state = { query: props.initQuery } } onSearchChange = (_, newValue: string) => { this.debouncedSearch(newValue) + this.setState({ query: newValue }) } componentDidUpdate(prevProps: SearchProps) { @@ -45,7 +51,7 @@ class ArticleSearch extends React.Component { componentRef={this.inputRef} className="article-search" placeholder={intl.get("search")} - defaultValue={this.props.initQuery} + value={this.state.query} onChange={this.onSearchChange} /> ) }