why-did-you-render + React Query

Author: scientist1642Created Aug 20, 2023Updated Aug 20, 2023

I wonder if someone has made it to work with react query, or if the library only works with certain type of hooks.

I have the following configuration, but updates to data doesn't cause it to log. const { data, error } = useQuery... whenever data updates component will re-render, but I don't see anything in console. (useState updates are visible though)

bash
export function enableWhyDidYouRender(react) {
  const ReactQuery = require("@tanstack/react-query");
  if (process.env.NODE_ENV !== "development") return;
  whyDidYouRender(react, {
    include: [/./],
    exclude: [],
    trackAllPureComponents: true,
    trackHooks: true,
    logOwnerReasons: true,
    logOnDifferentValues: true,
    collapseGroups: true,
    trackExtraHooks: [[ReactQuery, "useQuery"]],
  });
}

Source: welldone-software/why-did-you-render