Skip to content

Refresh Issue #117

@Minifish57

Description

@Minifish57

Hello everyone,

I followed the tutoriel React/Apollo and I faced some refresh issue with this project:

  • First when you log in , the Header seems not rerendered (you don't have the submit button even if you're logged in , see the image below, you can see that you are logged in cause you see the vote below links)
    Capture d’écran 2021-01-20 à 07 31 01

  • Then it seems that the pagination (or the data fetch by the query is not working well, or need to be refetched when page in URL change ?) - in my dataset I have 6 links
    First you are on the page one, you can see 5 links (normal behavior)
    Capture d’écran 2021-01-20 à 07 32 28
    Then you click on the next page on you see a new link (based on the pagination system , normal behavior)
    Capture d’écran 2021-01-20 à 07 32 39
    If you hit again previous button, there is on the page only one link (and not the 5 previous one , bug)
    Capture d’écran 2021-01-20 à 07 32 45

So is it a normal case with apollo ? do we need to have a useEffect hook in linklist.js like the code bellow ? The hook useQuery does not rerender the component in such cases ? or is it a problem with the InMemoryCache ?
(even in the apollo dev tools extension, the parameters variables for the FETCH Query seems not changing at all)

const history = useHistory();
  const isNewPage = history.location.pathname.includes("new");
  const pageIndexParams = history.location.pathname.split("/");
  const page = parseInt(pageIndexParams[pageIndexParams.length - 1]);

  const pageIndex = page ? (page - 1) * LINKS_PER_PAGE : 0;

  const { data, loading, error, subscribeToMore, refetch } = useQuery(
    FEED_QUERY,
    {
      variables: getQueryVariables(isNewPage, page),
    }
  );
useEffect(() => {
    console.log("refetch");
    refetch();
  }, [page]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions