score:0

//...

const channelListQuery = useQuery(
    ['channelList', pagination, searchCondition],
    async () => {
      const getChannelListParams = omitFalsyFields({
        currentPage: pagination.current,
        pageSize: pagination.pageSize,
        ...searchCondition,
      });
      const { code, result } = await apis.channel.getChannelList(getChannelListParams);
      if (code === '0') {
        return result;
      }
    },
    { initialData: { totalItem: 0, resultList: [] }, refetchOnWindowFocus: false, keepPreviousData: true, enabled: false },
  );

// onMount
useEffect(() => {
  channelListQuery.refetch();
}, [pagination])

// User click "Query" button
const handleSearchFormSubmit = () => {
  channelListQuery.refetch();
}

// ...

score:1

function App() {
 const [search, setSearch] = useState()
 const { data } = useQuery(['channelList', search], () => getChannelList(search), { enabled: !!search }

 <SearchFrom onSubmit={setSearch} />
}

Related Query

More Query from same tag