-
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
Use defaultProps instead of hardcoded value #10567
Conversation
<ScreenWrapper style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}]}> | ||
<ScreenWrapper | ||
style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}]} | ||
keyboardAvoidingViewBehavior={Platform.OS === 'android' ? '' : 'padding'} |
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 would refactor this to follow our JS guidelines
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 maybe we just ... wont? IDK...
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 mean if we want we could create something like getReportScreenScreenWrapperStyles()
-> index.js
'padding'
index.android.js
''
, but not really worth IMO.
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.
Coming in here because I ran into this warning:
Question: Why doesn't this default to "height" for android since that's what's being done in the android file above?
Request: Please refactor this to follow our platform conventions. Leaving code like this only let's contributors see the pattern and follow it. I recently read through the README section "Cross Platform 99.9999%" and it's a good refresher of why we do this. We should not compromise 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.
There was some conversation about this being temporary to help unblock the deploy but I'm guessing it just did not get cleaned up.
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.
IIRC @Julesssss found a better solution for this problem.
@@ -19,6 +20,8 @@ import ONYXKEYS from '../../ONYXKEYS'; | |||
import {withNetwork} from '../OnyxProvider'; | |||
import {propTypes, defaultProps} from './propTypes'; | |||
|
|||
propTypes.keyboardAvoidingViewBehavior = PropTypes.oneOf(['padding', 'height', 'position', '']).isRequired; |
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 not add these to 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.
They are in the prop types, but they're not required. index.android.js
and index.js
provide defaults, but BaseScreenWrapper
does not, so I just added it as a required prop 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.
sorry why does it need to be required?
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 see what you were suggesting. Done!
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 are still passing a default in the defaultProps
for this. so I think we can just remove this and if we want to be able to pass a string then add it here it's ok
App/src/components/ScreenWrapper/propTypes.js
Lines 24 to 25 in e6b6dd2
keyboardAvoidingViewBehavior: PropTypes.oneOf(['padding', 'height', 'position']), | |
?
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.
Think we still wanted to add the ''
here but maybe it's fine it will just do a warning 🤷
|
@marcaaron did the refactor you asked for, looks cleaner now |
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.
Watched him test it live 👀
Not including a video because I was testing on a physical device, but @Luke9389 witnessed me testing this and it working |
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 do the checklist
Can we fix this though -> https://github.com/Expensify/App/pull/10567/files#r955100321 I think it's wrong? |
b83498b
Use defaultProps instead of hardcoded value (cherry picked from commit 44b6637)
…-10567 🍒 Cherry pick PR #10567 to staging 🍒
🚀 Cherry-picked to staging by @Luke9389 in version: 1.1.89-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Cherry-picked to staging by https://github.com/AndrewGable in version: 1.3.28-2 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
Details
Fixed Issues
$ #10539
Tests / QA Steps
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
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)PR Reviewer Checklist
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
displayName
propertythis
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)QA Steps
Screenshots
Web
Mobile Web
Desktop
iOS
Android