title: Invalidate queries doesn't work [React-Query]
body: <p>I'm trying to invalidate queries every times users press button &quot;likes&quot; to refresh all queries but without success so far despite following the docs.</p>
  <p>I have a component that get data :</p>
  <pre><code>  const {
      data: resultsEnCours,
      isLoading,
      isError,
    } = useQueryGetEvents(&quot;homeencours&quot;, { currentEvents: true });
  </code></pre>
  <p>This is a custom hook which look like this :</p>
  <pre><code>const useQueryGetEvents = (nameQuery, params, callback) =&gt; {
    const [refetch, setRefetch] = React.useState(null);
    const refetchData = () =&gt; setRefetch(Date.now()); // =&gt; manual refresh
    const { user } = React.useContext(AuthContext);
    const { location } = React.useContext(SearchContext);
  
    const { isLoading, isError, data } = useQuery(
      [nameQuery, refetch],
      () =&gt; getFromApi(user.token, &quot;getEvents&quot;, { id_user: user.infoUser.id, ...params }),
      // home params =&gt; &quot;started&quot;, &quot;upcoming&quot;, &quot;participants&quot;
      {
        select: React.useCallback(({ data }) =&gt; filterAndSortByResults(data, location, callback), []),
      }
    );
  
    return { data, isLoading, isError, refetchData };
  };
  
  export default useQueryGetEvents;
  </code></pre>
  <p>And I have another component &quot;ButtonLikeEvent&quot; which allow the user to like or unlike an event:</p>
  <pre><code>import { useMutation, useQueryClient } from &quot;react-query&quot;;
  import { postFromApi } from &quot;../../api/routes&quot;; 
  ...other imports
  
  
  const ButtonLikeEvent = ({ item, color = &quot;#fb3958&quot; }) =&gt; {
    const queryClient = useQueryClient();
    const {
      user: {
        token,
        infoUser: { id },
      },
    } = React.useContext(AuthContext);
  
    const [isFavorite, setIsFavorite] = React.useState(item.isFavorite);
    const likeEventMutation = useMutation((object) =&gt; postFromApi(token, &quot;postLikeEvent&quot;, object));
    const dislikeEventMutation = useMutation((object) =&gt;
      postFromApi(token, &quot;postDislikeEvent&quot;, object)
    );
  
    const callApi = () =&gt; {
      if (!isFavorite) {
        likeEventMutation.mutate(
          { id_events: item.id, id_user: id },
          {
            onSuccess() {
              queryClient.invalidateQueries();
              console.log(&quot;liked&quot;);
            },
          }
        );
      } else {
        dislikeEventMutation.mutate(
          { id_events: item.id, id_user: id },
          {
            onSuccess() {
              queryClient.invalidateQueries();
              console.log(&quot;disliked&quot;);
            },
          }
        );
      }
    };
  
    return (
      &lt;Ionicons
        onPress={() =&gt; {
          setIsFavorite((prev) =&gt; !prev);
          callApi();
        }}
        name={isFavorite ? &quot;heart&quot; : &quot;heart-outline&quot;}
        size={30}
        color={color} //
      /&gt;
    );
  };
  
  export default ButtonLikeEvent;
  </code></pre>
  <p>Every time an user click on that button I'd like to invalidate queries (because many screens shows the like button).</p>
  <p>The console.log is displayed on success but the queries are not invalidate.</p>
  <p>Any idea ?</p>
  <p>thanks</p>