mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
921c9ff165
Summary: # The bug Sticky headers would not "stick" to the top of the ScrollView on initial render. On subsequent redners, all sticking would work correctly. # Why the bug existed This code to initialize the animated values used for sticky headers was in `UNSAFE_componentWillMount` prior to D26375818 (https://github.com/facebook/react-native/commit/1641d46529f33a1726b5c4f3429655314386c064). `UNSAFE_componentWillMount` is called before `render`. In D26375818 (https://github.com/facebook/react-native/commit/1641d46529f33a1726b5c4f3429655314386c064), I moved the code into `componentDidMount`, which is called after `render`. This caused a problem because code in `render` was relying on these initializations being done already. # How I resolved the bug To resolve this, I initialize these values in the constructor. # Reference Docs for React mount ordering: https://reactjs.org/docs/react-component.html#mounting Changelog: [General][Fixed] Fix sticky header not sticking on first render in ScrollView Reviewed By: nadiia Differential Revision: D26792003 fbshipit-source-id: c575e8cdd1d986ce3c38941d95d763e329e74874