Skip to content

Commit

Permalink
update side effect
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Feb 24, 2021
1 parent 5238f2f commit 4c74803
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { useState } from 'react';
import { useEffect, useState } from 'react';
import useDebounce from 'react-use/lib/useDebounce';
import { useUrlParams } from '../../../../hooks';

Expand All @@ -16,6 +16,10 @@ export const useSimpleQuery = () => {

const [debouncedValue, setDebouncedValue] = useState(query ?? '');

useEffect(() => {
setDebouncedValue(query ?? '');
}, [query]);

useDebounce(
() => {
updateUrlParams({ query: debouncedValue });
Expand Down

0 comments on commit 4c74803

Please sign in to comment.