mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Update the "results" state if "initialResultsState" array length is different (#15270)
This commit is contained in:
parent
d8a1b3bcc7
commit
2744eaf760
@ -1,4 +1,4 @@
|
||||
import React, { useState, useRef } from 'react';
|
||||
import React, { useState, useRef, useMemo, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import ItemList from './item-list';
|
||||
import ListItemSearch from './list-item-search';
|
||||
@ -22,7 +22,14 @@ export default function SearchableItemList({
|
||||
}) {
|
||||
const itemListRef = useRef();
|
||||
|
||||
const [results, setResults] = useState(defaultToAll ? itemsToSearch : []);
|
||||
const initialResultsState = useMemo(() => {
|
||||
return defaultToAll ? itemsToSearch : [];
|
||||
}, [defaultToAll, itemsToSearch]);
|
||||
const [results, setResults] = useState(initialResultsState);
|
||||
useEffect(() => {
|
||||
setResults(initialResultsState);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [initialResultsState.length]);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user