Skip to content
Discussion options

You must be logged in to vote

Solution

It is good to avoid anonymous functions because otherwise, the algorithm trying to figure out what to preserve can't do that very thing, specifically when HoCs are involved, or at least that's my take on it.

In your case this snippet should work. That is, give a name to the Component definition (returned function) from withAuthRequirement. In this case I call mine, Enhanced. I'd also recommend reading about naming conventions for HoCs.

const withNothing = <PageProps,>(Page: NextPage<PageProps>) => {
  return function Enhanced(props: PageProps) {
    const factor = 3;
    const mult = 2 * factor;

    return <Page {...props} />;
  };
};

or

const withNothing = <PageProps,>(Page: Ne…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PhanDungTri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants