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.
We would refactor this to follow our JS guidelines
There was a problem hiding this comment.
Or maybe we just ... wont? IDK...
There was a problem hiding this comment.
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.
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.
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.
IIRC @Julesssss found a better solution for this problem.
| import {withNetwork} from '../OnyxProvider'; | ||
| import {propTypes, defaultProps} from './propTypes'; | ||
|
|
||
| propTypes.keyboardAvoidingViewBehavior = PropTypes.oneOf(['padding', 'height', 'position', '']).isRequired; |
There was a problem hiding this comment.
Why not add these to propTypes?
There was a problem hiding this comment.
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.
sorry why does it need to be required?
There was a problem hiding this comment.
I see what you were suggesting. Done!
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 |
Luke9389
left a comment
There was a problem hiding this comment.
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 |
|
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 Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris 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 Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
Web
Mobile Web
Desktop
iOS
Android