-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
examplesRelating to /examples.Relating to /examples.
Description
Using examples/nextjs, when the page exported is wrapped with React.memo it error with:
Warning: Failed prop type: Invalid prop
Componentof typeobjectsupplied toMyApp, expectedfunction. in MyApp
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Steps to Reproduce 🕹
Clone the example
In pages/index.js wrap
export default function Index() { ... }with React.memo:
export default React.memo(function Index() { ... });Context 🔦
Note that React.memo is typed like so:
function memo<P extends object>(
Component: SFC<P>,
propsAreEqual?: (prevProps: Readonly<PropsWithChildren<P>>, nextProps: Readonly<PropsWithChildren<P>>) => boolean
): NamedExoticComponent<P>;
function memo<T extends ComponentType<any>>(
Component: T,
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean
): MemoExoticComponent<T>;The propType in _app.js should change from:
Component: PropTypes.func.isRequired,To:
Component: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,eps1lon and oxfist
Metadata
Metadata
Assignees
Labels
examplesRelating to /examples.Relating to /examples.