-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Changes from 7 commits
56172e9
dcb7386
0b620d0
f8b0614
8196502
d64538a
fd36698
ba7baf6
6535cea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
import React from 'react'; | ||||||
import {StyleProp, View, ViewStyle} from 'react-native'; | ||||||
import globalStyles from '../styles/styles'; | ||||||
import Icon from './Icon'; | ||||||
import * as Expensicons from './Icon/Expensicons'; | ||||||
import themeColors from '../styles/themes/default'; | ||||||
|
||||||
type SelectCircleProps = { | ||||||
/** Should we show the checkmark inside the circle */ | ||||||
isChecked: boolean; | ||||||
|
||||||
/** Additional styles to pass to SelectCircle */ | ||||||
styles?: StyleProp<ViewStyle>; | ||||||
}; | ||||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Typescript made me get rid of the spread operator ( There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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; |
||||||
{isChecked && ( | ||||||
<Icon | ||||||
src={Expensicons.Checkmark} | ||||||
fill={themeColors.iconSuccessFill} | ||||||
/> | ||||||
)} | ||||||
</View> | ||||||
); | ||||||
} | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should always define displayName:
Suggested change
|
||||||
SelectCircle.displayName = 'SelectCircle'; | ||||||
|
||||||
export default SelectCircle; |
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