hama
hama

Reputation: 1

msw did not mocking useLazyQuery at first rendering

I using useLazyQuery for fetching data and mocking that request's response in development environment.

...
  const [getSiteList, { data }] = useLazyGetSiteListQuery();

  useEffect(() => {
    void getSiteList({});
  }, [getSiteList]);

  console.log(data)

When I run this code it returns real api's data. But it returns mocking data when i annotate the console.log and back-annotate. I think it would be asynchronous problem but don't know how to solve this problem.

Environment

I want to get mocking data even if it has been first render.

Upvotes: 0

Views: 43

Answers (0)

Related Questions