-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
migrated ScrollViewWithContext to a functional component #23879
migrated ScrollViewWithContext to a functional component #23879
Conversation
@s77rt I was wondering what screenshots should I add in the PR?
i don't think it'll be a good idea to find all 38+ places and add 38+ screenshots |
@Parshvi16 You should test for all or as many as possible cases (depends) but for the screenshots you can just add for one case |
} | ||
} | ||
ScrollViewWithContext.propTypes = propTypes; | ||
const ScrollViewWithContext = React.forwardRef( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write this as function ScrollViewWithContext
and we don't need React.forwardRef
we already forward the ref in the exported function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
const ScrollViewWithContext = React.forwardRef( | ||
({ onScroll, scrollEventThrottle, children, innerRef, ...restProps }, ref) => { | ||
const [contentOffsetY, setContentOffsetY] = useState(0); | ||
const scrollViewRef = innerRef || ref || defaultScrollViewRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the fallback ref we should use useRef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. can't add directly useRef(null)
in line 15 in place of defaultScrollViewRef
because it throughs error that useRef cannot be called conditionally.
)); | ||
|
||
export {ScrollContext}; | ||
export { ScrollContext }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing new line. Please run prettier (npm run prettier
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
); | ||
|
||
ScrollViewWithContext.propTypes = propTypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add displayName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@s77rt I've added the screenshots and have addressed all the suggestions, so the PR is ready from my side. |
function ScrollViewWithContext({onScroll, scrollEventThrottle, children, innerRef, ...restProps}, ref) { | ||
const [contentOffsetY, setContentOffsetY] = useState(0); | ||
const defaultScrollViewRef = useRef(); | ||
const scrollViewRef = innerRef || ref || defaultScrollViewRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still have innerRef and ref? Shouldn't it be just innerRef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed extra ref
/* | ||
* <ScrollViewWithContext /> is a wrapper around <ScrollView /> that provides a ref to the <ScrollView />. | ||
* <ScrollViewWithContext /> can be used as a direct replacement for <ScrollView /> | ||
* if it contains one or more <Picker /> / <RNPickerSelect /> components. | ||
* Using this wrapper will automatically handle scrolling to the picker's <TextInput /> | ||
* when the picker modal is opened | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the comment back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ref={scrollViewRef} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...restProps} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref={scrollViewRef} | |
// eslint-disable-next-line react/jsx-props-no-spreading | |
{...restProps} | |
// eslint-disable-next-line react/jsx-props-no-spreading | |
{...restProps} | |
ref={scrollViewRef} |
NAB but in general it's better to spread the props at first so they don't overwrite our custom passed props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@s77rt again, added all the suggested changes |
@Parshvi16 Please add tests steps and for the screenshot you should attach a video/screenshot for something that was effected by this PR. Prerequisites: Have a workspace (with USD set as the default currency)
Kooha-2023-07-31-19-01-21.mp4 |
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
@s77rt updated the Test steps and added the test videos in the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
@madmax330 before merging, please assign me to the issue. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/madmax330 in version: 1.3.49-0 🚀
|
🚀 Deployed to staging by https://github.com/madmax330 in version: 1.3.50-0 🚀
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.49-3 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
Details
Migrated ScrollViewWithContext.js to a functional component
Fixed Issues
$ #16200
PROPOSAL: #16200 (comment)
Tests
Prerequisites: Have a workspace (with USD set as the default currency)
Offline tests
Same as online tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-08-01.at.11.35.37.AM.mov
Mobile Web - Chrome
Screen.Recording.2023-08-01.at.11.50.12.AM.mov
Mobile Web - Safari
Screen.Recording.2023-08-01.at.11.40.13.AM.online-video-cutter.com.mp4
Desktop
Screen.Recording.2023-08-01.at.11.46.33.AM.online-video-cutter.com.mp4
iOS
Screen.Recording.2023-08-01.at.11.38.56.AM.mov
Android
257311646-01b41d33-c0eb-4f21-bad0-197eba53ec32.mp4