-
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
[TS migration] Migrate 'SelectCircle.js' component to TypeScript #30077
[TS migration] Migrate 'SelectCircle.js' component to TypeScript #30077
Conversation
</View> | ||
); | ||
} | ||
|
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.
We should always define displayName:
SelectCircle.displayName = 'SelectCircle'; |
src/components/SelectCircle.tsx
Outdated
isChecked: boolean; | ||
|
||
/** Additional styles to pass to SelectCircle */ | ||
styles: Array<Record<string, unknown>>; |
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.
Please use more accurate type here, ViewStyle[]
?
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.
OR let's do it the same as in this PR
|
||
function SelectCircle({isChecked = false, styles = []}: SelectCircleProps) { | ||
return ( | ||
<View style={[globalStyles.selectCircle, globalStyles.alignSelfCenter, styles]}> |
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.
Typescript made me get rid of the spread operator (...styles
-> styles
) after I switched from an Array<>
to StyleProp<>
. But the weird thing is that it still works when styles are passed like they used to be: <SelectCircle isChecked={props.isSelected} styles={[styles.singleOptionSelectorCircle]} />
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.
If it works, that's fine with me. Please test that the styles are displayed correctly.
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.
Yes, works just fine
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.
Should we check that styles isn't null?
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.
@cead22 Styles accept falsy values, so no need for such check:
type Falsy = undefined | null | false;
export type StyleProp<T> =
| T
| RegisteredStyle<T>
| RecursiveArray<T | RegisteredStyle<T> | Falsy>
| Falsy;
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.
@MaciejSWM I think we should update the PR title to [TS migration] Migrate 'SelectCircle.js' component to TypeScript
, in order to QA team to test it.
Co-authored-by: Fábio Henriques <fabio.lacerda@outlook.com>
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
@cubuspl42 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] |
Reviewer Checklist
Screenshots/VideosWebselect-circle-web.mp4Mobile Web - Chromeselect-circle-android-web-compressed.mp4Mobile Web - Safariselect-circle-ios-web.mp4DesktopiOSselect-circle-ios.mp4Androidselect-circle-android-compressed.mp4 |
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25015 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
isChecked: boolean; | ||
|
||
/** Additional styles to pass to SelectCircle */ | ||
styles?: StyleProp<ViewStyle>; |
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.
Is there no way to define a default for this prop like []?
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.
It is possible, we can default it to []. cc @MaciejSWM
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.
Hey @cead22. Thanks for spotting this. It turns out that no action is needed, as RN+TS still work well when styles
are undefined. Please see this:
https://github.com/Expensify/App/pull/29988/files#r1373207252
Especially the first example that passes no styles to FullScreenLoadingIndicator
: https://github.com/Expensify/App/pull/29988/files#r1374544242
|
||
function SelectCircle({isChecked = false, styles = []}: SelectCircleProps) { | ||
return ( | ||
<View style={[globalStyles.selectCircle, globalStyles.alignSelfCenter, styles]}> |
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.
Should we check that styles isn't null?
✋ 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/cead22 in version: 1.3.96-0 🚀
|
@MaciejSWM Could you please share the QA steps. We need help with the following steps in "Tests" section.
|
I updated the QA section @kavimuru. It will be enough just to test if the SelectCircle component works correctly in the app, no need to change the background color as it was just to highlight more easily that you're looking at the correct component. |
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀
|
Details
Fixed Issues
$ #25015
PROPOSAL:
Tests
styles.ts
findselectCircle
and change it's background color to something bright:backgroundColor: 'red',
Start Chat
, clickAdd to group
for a couple of users. You should see the SelectCircle component working correctly, and having a red background:Offline tests
QA Steps
QA Steps
Start Chat
, clickAdd to group
for a couple of users. You should see the SelectCircle component working correctly.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
Android: Native
Screen.Recording.2023-10-20.at.15.32.18.mov
Android: mWeb Chrome
Screen.Recording.2023-10-20.at.15.33.28.mov
iOS: Native
Screen.Recording.2023-10-20.at.15.13.06.mov
iOS: mWeb Safari
Screen.Recording.2023-10-20.at.15.14.24.mov
MacOS: Chrome / Safari
Screen.Recording.2023-10-20.at.15.34.59.mov
MacOS: Desktop
Screen.Recording.2023-10-20.at.15.35.40.mov