-
Notifications
You must be signed in to change notification settings - Fork 24.8k
removed defaultProps and replaced it with a default value where nece… #32133
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
removed defaultProps and replaced it with a default value where nece… #32133
Conversation
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.
Thanks for getting to this! Just the main question about using this.props.drawerBackgroundColor
@@ -56,7 +56,7 @@ type Props = $ReadOnly<{| | |||
* ); | |||
* ``` | |||
*/ | |||
drawerBackgroundColor: ColorValue, |
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.
nit: space
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.
actually we need this in Props i have added it back
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 shouldn't remove this prop as users should still be able to specify a backgroundColor other than the default
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.
when we keep this as a part of "Props", it throws an error which says -- """element because property drawerBackgroundColor
is missing in
props [1] but exists in Props
[2]. [prop-missing]""". Any work around for this? @lunaleaps ? I dont get this error when is do a 'yarn test' locally but from the CI windows-test suite.
@@ -189,7 +185,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> { | |||
styles.drawerSubview, | |||
{ | |||
width: this.props.drawerWidth, | |||
backgroundColor: this.props.drawerBackgroundColor, | |||
backgroundColor: this.props.drawerBackgroundColor || 'white', |
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 do we do this? why not use drawerBackgroundColor
?
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 have removed the const declaration of drawerBackgroundColor above, we can use the || operator at the site of usage, it seems more intuitive.
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'd actually suggest the alternative as other (unlikely) usages of drawerBackgroundColor might come up and not pass 'white' as a default
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.
Sure thanks for the suggestion @lunaleaps ! will go with the earlier approach and not use this.props.drawerBackgroundColor
Base commit: 8c25711 |
…rawerBackgroundColor
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
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Hey @mdaj06, |
Hi @cortinico looks like my fork was 80 commits behind, i have now fetched upstream and have merged those commits from main to my branch. This should work i guess please correct me if i am wrong.Thanks! |
Some of the CI failures are valid:
Can I ask you to take a look at them? Let us know if you get stuck 👍 |
@cortinico okay sure will have a look at this and get back to you! |
Base commit: 8c25711 |
…ponent since the native component expects it
…as a default inside render()
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js
Outdated
Show resolved
Hide resolved
Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js
Outdated
Show resolved
Hide resolved
@cortinico I have removed the drawerBackgroundColor from Props as we are giving it a default value later on. Also have added a prop seperately to the AndroidDrawerLayoutNativeComponent such that the native component can run as expected. Does that look good to you? |
…aultProps drawerBackgroundColor
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.
Does that look good to you?
It does 👍
Please remove the gradlew
file change that should not be included.
Handing over to @lunaleaps for merging this
@@ -1,89 +1,89 @@ | |||
@rem |
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.
Do not add this file (valid for all the gradlew
files).
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.
oh yes must have got in there during my earlier commit! sorry! will remove it asap
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.
Just to clarify: you don't need to remove the file, but just to amend the changes 👍
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.
As @cortinico mentioned, we shouldn't be deleting these files, just undo your changes.. and similarly for the other gradlew.bat files. We probably shouldn't be touching those. @cortinico to verify
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.
sure will reinstatie them
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@@ -56,7 +56,7 @@ type Props = $ReadOnly<{| | |||
* ); | |||
* ``` | |||
*/ | |||
drawerBackgroundColor: ColorValue, |
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 shouldn't remove this prop as users should still be able to specify a backgroundColor other than the default
@@ -1,89 +1,89 @@ | |||
@rem |
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.
As @cortinico mentioned, we shouldn't be deleting these files, just undo your changes.. and similarly for the other gradlew.bat files. We probably shouldn't be touching those. @cortinico to verify
…ture/reafctorDrawerLayoutAndroidV2
Feature/reafctor drawer layout android v2
closed this PR as it got too messy will reopen one @lunaleaps with the suggested changes. |
Summary
Removed the deaultProps in the DrawerLayoutAndroid file and replaced it with a default value in case props are undefined.
Changelog
[General] [Changed] - Remove defaultProps from the DrawerLayoutAndroid Component.
@lunaleaps this is the fix for issue #31606
Test Plan
tested on simulator