Definitelytyped: Regression: `renderItem` in `SectionListProperties` is no longer optional

Created on 2 Mar 2018  路  5Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

  • [x] I tried using the @types/react-native package and had problems.
  • [X] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [X] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [X] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @bedemiralp @alloy @timwangdev @kamal @nelyousfi @iRoachie @huhuanming

If you do not mention the authors the issue will be ignored.

Commit 2f9d9fad25 caused a regression where renderItem used to be optional, it is now required, breaking cases where all sections in a SectionList has a renderItem.

All 5 comments

Found the offending PR: #22403

@tn0502 Thank you for reporting the issue.

At the time PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/22403 was submitted, renderItem seemed to be an optional prop but it no longer is.

I will fix this issue and submit a PR over the weekend.

Background

  • "renderItem" used be required prop for SectionList component up until RN 0.48.
  • SectionList props and methods were not fully documented on versions 0.49 through 0.51.
  • RN reference documents for 0.52 and up, including 0.54, declare the "renderItem" as an optional prop.

@bedemiralp The docs have definitely shown to be out of sync with the actual source from time to time, so probably best to check the source (and maybe PR doc changes to RN?).

@bedemiralp I think what happened is that you're trusting the docs to be correct. When SectionList was introduced in 0.42, renderItem was optional. You can see it in code: https://github.com/facebook/react-native/blob/0.44-stable/Libraries/Lists/SectionList.js. This has not changed till this day.

Edit: Or what @alloy said :)

Was this page helpful?
0 / 5 - 0 ratings