react / react/react-native-website

Ambiguity on why the index property in ViewToken is marked optional

Open
#3,637 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Never gets stale
Dominant language
MDX
Stars
2.2k
Forks
6.3k
Avg merge
11h 37m
Merged PRs (30d)
19

Description

Description

On the ViewToken page in the docs it shows that the index property is optional. This is not explained in any further detail by the docs.

What is the problem?

It is unclear to me in what situation this property would be null. This object is used as a parameter for the onViewableItemsChanged callback in VirtualizedList so it is in turn also used in both FlatList and SectionList. This makes me think there wouldn't be a situation where index would be null.

How can we address it?

Update the description of the index property on ViewToken to clarify in what situation it could be null.

If anyone knows a resource like an issue in the react-native repo or a from post that discusses this or can explain it to me I can also make a PR to clarify the description on the property.

Why is it important?

It is currently ambiguous why the index property on ViewToken is marked as optional.

Who needs this?

Anyone using the onViewableItemsChanged prop and relies on the indexes of the callback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ViewToken page in the React Native documentation and inspect the description of its optional index property. Review how ViewToken is used by the onViewableItemsChanged callback in VirtualizedList, FlatList, and SectionList, then confirm the situation that permits a null index. Update the property description to explain that situation and verify the rendered documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.