Skip to content

Conversation

mdaj06
Copy link
Contributor

@mdaj06 mdaj06 commented Sep 1, 2021

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2021
@lunaleaps lunaleaps self-assigned this Sep 1, 2021
Copy link
Contributor

@lunaleaps lunaleaps left a 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

@mdaj06 mdaj06 Sep 6, 2021

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',
Copy link
Contributor

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?

Copy link
Contributor Author

@mdaj06 mdaj06 Sep 1, 2021

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.

Copy link
Contributor

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

Copy link
Contributor Author

@mdaj06 mdaj06 Sep 2, 2021

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

@analysis-bot
Copy link

analysis-bot commented Sep 1, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 8c25711

Copy link
Contributor

@lunaleaps lunaleaps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@facebook-github-bot
Copy link
Contributor

@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cortinico
Copy link
Contributor

Hey @mdaj06,
Don't you mind rebasing your branch on top of main. A lot of the CI failures have been fixed and seems like you don't have the fixes in your branch yet

@mdaj06
Copy link
Contributor Author

mdaj06 commented Sep 2, 2021

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!

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Sep 2, 2021
@cortinico
Copy link
Contributor

Some of the CI failures are valid:


Cannot create `AndroidDrawerLayoutNativeComponent` element because property `drawerBackgroundColor` is missing in
props [1] but exists in `NativeProps` [2]. [prop-missing]

   Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js:216:8
   216|       <AndroidDrawerLayoutNativeComponent
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Can I ask you to take a look at them? Let us know if you get stuck 👍

@mdaj06
Copy link
Contributor Author

mdaj06 commented Sep 2, 2021

@cortinico okay sure will have a look at this and get back to you!

@analysis-bot
Copy link

analysis-bot commented Sep 2, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,957,335 -13
android hermes armeabi-v7a 8,490,628 +1
android hermes x86 9,377,554 -13
android hermes x86_64 9,342,875 -12
android jsc arm64-v8a 10,639,601 +9
android jsc armeabi-v7a 9,560,403 +13
android jsc x86 10,654,101 +11
android jsc x86_64 11,263,105 +14

Base commit: 8c25711

Copy link

@analysis-bot analysis-bot left a 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. Run yarn lint --fix to automatically fix problems.

@mdaj06
Copy link
Contributor Author

mdaj06 commented Sep 2, 2021

@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?
EDIT:i have updated the snapshot test as well

@mdaj06 mdaj06 requested a review from lunaleaps September 2, 2021 14:38
Copy link
Contributor

@cortinico cortinico left a 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
Copy link
Contributor

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).

Copy link
Contributor Author

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

Copy link
Contributor

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 👍

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will reinstatie them

@facebook-github-bot
Copy link
Contributor

@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,
Copy link
Contributor

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
Copy link
Contributor

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

@pull-bot
Copy link

pull-bot commented Sep 6, 2021

Warnings
⚠️ 🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.

Generated by 🚫 dangerJS against 66384ef

@mdaj06 mdaj06 closed this Sep 6, 2021
@mdaj06
Copy link
Contributor Author

mdaj06 commented Sep 6, 2021

closed this PR as it got too messy will reopen one @lunaleaps with the suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Needs: Attention Issues where the author has responded to feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants