Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the prop 'renderItem' of List component be optional in TypeScript interface, or the example code in the Document has a bug? #16587

1 task done
ElizurHz opened this issue May 14, 2019 · 0 comments


Copy link

@ElizurHz ElizurHz commented May 14, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Steps to reproduce

Use a List component in a react app, without renderItem prop

What is expected?

‘renderItem’ is required in the interface ListProps. As the react-virtualized example in the document of List component shown, 'renderItem' is not used and there should not be any type error.

What is actually happening?

Actually in TypeScript environment, the 'prop' renderItem is required and if I copy the example code to my project, it will raise an TypeScript error:

Property 'renderItem' is missing in type '{ children: Element; grid: { gutter: number; sm: 1; md: 2; lg: 3; xl: 4; xxl: 6; }; }' but required in type 'Pick<Readonly<PropsWithChildren<ListProps<{}>>>, "children" | "footer" | "header" | "className" | "id" | "grid" | "prefixCls" | "extra" | "itemLayout" | "loadMore" | "rowKey" | "renderItem" | "size" | "locale">'.ts(2741)
index.d.ts(36, 5): 'renderItem' is declared here.
Environment Info
antd 3.16.3
React 16.8.4
System macOS Mojave 10.14.4
Browser Chrome 74.0.3729.131

Although I use antd@3.16.3, the definition of renderItem is still not optional in the latest version of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants