Skip to content
Discussion options

You must be logged in to vote

I found a solution.
After component mounted, remove the initialData.

My hook to check the component of mount state here.

import { useState, useEffect } from 'react';

const useMounted = () => {
  const [mounted, setMounted] = useState(false);

  useEffect(() => {
    setMounted(true);
  }, []);

  return mounted;
};

export default useMounted;

And my custom useQuery hook here.

const mounted = useMounted();
const { data } = useGetPosts(
  {
    filter: JSON.stringify({ categories: selectedCategory })
  },
  {
    suspense: true,
    useErrorBoundary: true,
    initialData: !mounted ? initialPosts : undefined
  }
);

If initialData is exist, suspense doesn't seem to be working well.
Is there…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by byseop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant