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

FlatList onScroll corner case bug: contentOffset undefined #15725

Closed
peacechen opened this issue Aug 31, 2017 · 4 comments
Closed

FlatList onScroll corner case bug: contentOffset undefined #15725

peacechen opened this issue Aug 31, 2017 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@peacechen
Copy link

Environment

  1. react-native -v: 0.45.1
  2. node -v: 7.0
  3. npm -v: 3.10
  • Target Platform: iOS 10.2

  • Development Operating System: OSX 10.12

  • Build tools: react-native & Xcode

Steps to Reproduce

This is a corner case bug that happens sporadically in a production build. It hasn't happened yet in a debug build. In the onScroll callback for FlatList, the argument passed in is incomplete. event.nativeEvent.contentOffset is undefined. The crash report came from NewRelic:

RCTFatalException: Unhandled JS Exception: undefined is not an object (evaluating 'e.y')
in 0x1000f3ea0 0 + 4295966368
Unhandled JS Exception: undefined is not an object (evaluating 'e.y'), stack: value@304:8561 value@304:6956 u@94:142 invokeGuardedCallbackAndCatchFirstError@94:580 c@110:365 a@110:567 v@154:502 i@157:95 processEventQueue@154:1433 s@165:88 handleTopLevel@165:174 <unknown>@164:574 perform@185:596 u@108:150 _receiveRootNodeIDEvent@164:546 receiveEvent@164:656 value@22:2893 <unknown>@22:832 value@22:2294 value@22:804

There is only one line in our app that references a .y key:

	onScroll(event) {
		let newScrollOffset = event.nativeEvent.contentOffset.y;
		// ...
	}

FlatList is instantiated as:

	<FlatList
		keyboardShouldPersistTaps={'handled'}
		removeClippedSubviews={true}
		data={this.state.listData}
		extraData={this.state.dataFilter}
		renderItem={this.renderSomething}
		keyExtractor={(item, index) => item.id}
		ListHeaderComponent={this.renderHeader(this.state.headerState)}
		onScroll={this.onScroll.bind(this)}
		scrollEventThrottle={100}
		onRefresh={this.renderRefresh}
		refreshing={this.state.refreshing}
	/>

Expected Behavior

contentOffset should be a valid object.

Actual Behavior

contentOffset is undefined. Is it possible for contentOffset to be undefined in the event parameter?

Reproducible Demo

Won't reproduce in a debugger.

@pull-bot
Copy link

pull-bot commented Oct 9, 2017

Hey, thanks for reporting this issue!

It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the template? This is necessary for people to be able to understand and reproduce the issue being reported.

I am going to close this, but feel free to open a new issue that meets the requirements set forth in the template. Thanks!

@peacechen
Copy link
Author

peacechen commented Oct 9, 2017

What other information would you like? It's a bug, and I've read the contribution guidelines.
@hramos

There isn't a Snack that reproduces it in the debugger. A fix would be to add a guard that ensures the event param is populated with x, y and other necessary keys.

@hramos
Copy link
Contributor

hramos commented Oct 10, 2017

Our bot is pretty simplistic at the moment, and it did not see the first few lines from the template here, hence why it deemed this issue as not following the template.

I did look at the issue and there doesn't seem to be a repro here that we can use to follow up, however. If you think such a guard would help, could you send a PR?

@peacechen
Copy link
Author

Created PR #16275

The safeguard check is done on the JS side. There may be a more comprehensive solution on the Event itself (native side? not sure).

@facebook facebook locked as resolved and limited conversation to collaborators Oct 9, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants