-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[TS migration] Migrate 'Picker' and 'LocalePicker' components to TypeScript #30646
[TS migration] Migrate 'Picker' and 'LocalePicker' components to TypeScript #30646
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
# Conflicts: # src/components/Picker/BasePicker.js
# Conflicts: # src/components/LocalePicker.js
src/components/Picker/BasePicker.tsx
Outdated
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [items]); | ||
|
||
const context = useContext(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.
I think it would be good to move it to ScrollContext file and extract it to seperate function lik
const context = useContext(ScrollContext); | |
const useScrollContext = () => useContext(ScrollContext); |
so then we only need to import useScrollContext
here
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.
@kubabutkiewicz Maybe we should create a separate custom hook then? Cause I have found only two approaches in the codebase:
- using context as in the current version (another example is PopoverContext usage)
- separate custom hook - useLocalize for example
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.
Separate custom hook is what I was suggesting here, so I would go with similar approach as useLocalize 😄
src/components/Picker/BasePicker.tsx
Outdated
|
||
if (isDisabled) { | ||
return ( | ||
<View key={inputID}> |
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 did you add key={inputID}
? afaik inputID
is only used internally inside Form
logic.
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.
Initially there was a forwardRef
which also added an inputID key to the element.
But during this discussion it was updated.
@fabioh8010 So do you think it makes sense to revert it all (including forwardRef
logic)?
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.
Yeah I think it would be safer to revert it 🤔
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
# Conflicts: # package-lock.json # package.json # src/components/Picker/BasePicker.js
@aimane-chnaif kind bump 🙂 |
@@ -143,7 +143,7 @@ | |||
"react-native-pdf": "^6.7.3", | |||
"react-native-performance": "^5.1.0", | |||
"react-native-permissions": "^3.9.3", | |||
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#eae05855286dc699954415cc1d629bfd8e8e47e2", | |||
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#0d15d4618f58e99c1261921111e68ee85bb3c2a8", |
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.
Picker needs to be fully tested as this change includes Expensify/react-native-picker-select#14 which has lots of upstream changes
// but doesn't open the picker (which we don't want), like it does on | ||
// Native. | ||
shouldFocusPicker | ||
key={props.inputID} |
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.
Any error without this line? This was not existed before
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.
@aimane-chnaif Initially there was a forwardRef which also added a key with inputID
.
App/src/components/Picker/BasePicker.js
Lines 298 to 307 in d2056af
const BasePickerWithRef = React.forwardRef((props, ref) => ( | |
<BasePicker | |
// eslint-disable-next-line react/jsx-props-no-spreading | |
{...props} | |
// Forward the ref to BasePicker, as we implement imperative methods there | |
forwardedRef={ref} | |
// eslint-disable-next-line react/prop-types | |
key={props.inputID} | |
/> | |
)); |
During TS migration forwardRef
was refactored to align with other TS files so the key
prop was moved from the BasePicker
file to the BasePicker
usage inside Picker
files.
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movandroid2.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.movios2.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
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 🎉
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25063 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Regarding snyk tests failure, I think this happens on all PRs which touched package file |
# Conflicts: # src/components/Picker/BasePicker.js
As there was conflict, please retest all 3 test cases on platforms to be safe |
@aimane-chnaif I've retested only one case on all platforms and will be able to test 2 more tomorrow morning only 🌃. |
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.
🎉
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.
Looks good and tests well 👍
✋ 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/deetergp in version: 1.4.9-0 🚀
|
1 similar comment
🚀 Deployed to staging by https://github.com/deetergp in version: 1.4.9-0 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.9-5 🚀
|
Details
[TS migration] Migrate 'Picker' and 'LocalePicker' components to TypeScript
Fixed Issues
$ #25063
$ #25091
PROPOSAL: N/A
Tests
First test case:
Second test case:
Third test case:
Storybook
Look through Pickers in the storybook and make sure it looks as expected.
Offline tests
QA Steps
The same as the Tests 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
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
Android: Native
android_locale.mp4
android1.mp4
android2.mp4
Android: mWeb Chrome
android_web3.mp4
android_web2.mp4
android_web1.mp4
iOS: Native
ios1.mp4
ios2.mp4
ios_locale.mp4
iOS: mWeb Safari
ios_web_locale.mp4
ios_web1.mp4
ios_web2.mp4
MacOS: Chrome / Safari
web_locale.mp4
web2.mp4
web1.mp4
MacOS: Desktop
desktop_locale.mp4
desktop2.mp4
desktop1.mp4
Storybook