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

[Bug][FlatList] assigning object to viewabilityConfig prop in render method triggers error #16710

Closed
eballeste opened this issue Nov 7, 2017 · 6 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@eballeste
Copy link

eballeste commented Nov 7, 2017

Is this a bug report?

Yup.

Have you read the Contributing Guidelines?

Yup.

Environment

OS: OS X El Capitan 10.11.6
Node: 7.10.0
Yarn: 0.24.6
npm: 4.2.0
Watchman: 4.9.0
Xcode: Xcode 8.2.1 Build version 8C1002
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.50.1 => 0.50.1

Steps to Reproduce

Use a flatlist with a viewabilityConfig.viewAreaCoveragePercentThreshold prop set to any value.
e.g: viewabilityConfig={{ viewAreaCoveragePercentThreshold: 50 }}.

<View>
    <FlatList
      data={[{a: foo}, {b: bar}, {c: foobar}]}
      viewabilityConfig={{ viewAreaCoveragePercentThreshold: 50 }}
    />
</View>

Expected Behavior

Normal use of a viewabilityConfig prop on a FlatList.

Actual Behavior

Use of viewabilityConfig throws errors caused by checks introduced in the following commit: ad733ad

Get Invariant violations, testing for equality, console.log spits out equal values, throws error regardless.

FlatList.js (425-428):

invariant(
      nextProps.viewabilityConfig === this.props.viewabilityConfig,
      'Changing viewabilityConfig on the fly is not supported',
);

screen shot 2017-11-06 at 7 25 35 pm

Reproducible Demo

Can't reproduce error on snack.

@eballeste
Copy link
Author

eballeste commented Nov 7, 2017

@Vince0613 @sahrens

@eballeste
Copy link
Author

I'm guessing the objects in prop are not considered equal because they are recreated on each re-render?? Is this what's happening?

@eballeste
Copy link
Author

Fixed this by setting the properties as a constant outside of the render method, but still not sure if these invariant checks should be doing equality checks by reference...

@eballeste eballeste changed the title [FlatList] viewabilityConfig prop bug [Bug][FlatList] assigning object to viewabilityConfig prop in render method triggers error Nov 8, 2017
@stale
Copy link

stale bot commented Jan 7, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 7, 2018
@smithaitufe
Copy link

I still have this issue despite setting the viewabilityConfig as a constant outside of my class. It happens when the app is refreshing or reloading. Please fix this asap.

@rikur
Copy link

rikur commented Feb 24, 2018

Please re-open, this is still an issue. I second that it shouldn't be checked by reference.

@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants