Replace string ref with React.createRef for ScrollView #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor ScrollView reference handling to use React.createRef() instead of a string reference.
Problem
The ParallaxScrollView component was using the legacy string refs pattern (ref="ScrollView"), which has been deprecated since React 16.3 and completely removed in React 18+. This caused a runtime error:
"TypeError: Cannot create property 'current' on string 'ScrollView'"
Solution
Migrated all string refs to use React.createRef() for class component compatibility with modern React Native and Expo SDK.
Changes Made
✅ Replaced string ref SCROLLVIEW_REF = 'ScrollView' with this.scrollViewRef = React.createRef()
✅ Replaced footer callback ref with React.createRef() pattern
✅ Updated all ref access patterns (this.refs[SCROLLVIEW_REF] → this.scrollViewRef.current)
✅ Added optional chaining for safer ref access in public methods
Testing Checklist
Component renders without errors
Parallax scrolling effect works correctly
Sticky header behavior is intact
Background/foreground fade animations work
Public API methods (scrollTo, getScrollResponder, etc.) function properly
No console warnings related to refs
Tested on both iOS and Android (via Expo Go)
Breaking Changes
None - This is a drop-in replacement that maintains the exact same public API.
Dependencies
No new dependencies required. Compatible with:
React 18+
React Native 0.70+
Expo SDK 47+
Related Issues
Fixes #[issue-number] - TypeError on ParallaxScrollView initialization
Type: Bug Fix
Priority: High (blocking component usage)
Reviewer: @jaysoo @dmfrancisco @AndrewJack @alaycock