remove react effect for less potential re-rendering
Signed-off-by: headphonejames <generalfuzz@gmail.com>
This commit is contained in:
+6
-5
@@ -95,11 +95,12 @@ export function EntityAutocompletePicker<
|
||||
|
||||
// Set selected options on query parameter updates; this happens at initial page load and from
|
||||
// external updates to the page location
|
||||
useEffect(() => {
|
||||
if (queryParameters.length) {
|
||||
setSelectedOptions(queryParameters);
|
||||
}
|
||||
}, [queryParameters]);
|
||||
const [prevQueryParameters, setQueryParameter] = useState(queryParameters);
|
||||
// if the query parameter has changed, update the selected options
|
||||
if (queryParameters !== prevQueryParameters) {
|
||||
setSelectedOptions(queryParameters);
|
||||
setQueryParameter(queryParameters);
|
||||
}
|
||||
|
||||
const availableOptions = Object.keys(availableValues ?? {});
|
||||
const shouldAddFilter = selectedOptions.length && availableOptions.length;
|
||||
|
||||
@@ -222,7 +222,6 @@ describe('<EntityTagPicker/>', () => {
|
||||
tags: new EntityTagFilter(['tag1']),
|
||||
}),
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByTestId('tags-picker-expand'));
|
||||
fireEvent.click(screen.getByLabelText('tag2'));
|
||||
expect(screen.getByLabelText('tag2')).toBeChecked();
|
||||
|
||||
Reference in New Issue
Block a user