Skip to content

Commit b998e32

Browse files
mdaj06facebook-github-bot
authored andcommitted
removed default props for drawerBackgroundColor and fixed lint issues (#32162)
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 Pull Request resolved: #32162 Test Plan: Ran test suite Reviewed By: lunaleaps Differential Revision: D30776242 Pulled By: cortinico fbshipit-source-id: 51408acd92aecb8d725b0bbf39ddb059924481e5
1 parent cb58c84 commit b998e32

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Props = $ReadOnly<{|
5656
* );
5757
* ```
5858
*/
59-
drawerBackgroundColor: ColorValue,
59+
drawerBackgroundColor?: ?ColorValue,
6060

6161
/**
6262
* Specifies the side of the screen from which the drawer will slide in.
@@ -161,11 +161,6 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
161161

162162
return {Left: 'left', Right: 'right'};
163163
}
164-
static defaultProps: {|
165-
drawerBackgroundColor: 'white',
166-
|} = {
167-
drawerBackgroundColor: 'white',
168-
};
169164

170165
_nativeRef = React.createRef<
171166
React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>,
@@ -175,6 +170,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
175170

176171
render(): React.Node {
177172
const {
173+
drawerBackgroundColor = 'white',
178174
onDrawerStateChanged,
179175
renderNavigationView,
180176
onDrawerOpen,
@@ -189,7 +185,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
189185
styles.drawerSubview,
190186
{
191187
width: this.props.drawerWidth,
192-
backgroundColor: this.props.drawerBackgroundColor,
188+
backgroundColor: drawerBackgroundColor,
193189
},
194190
]}
195191
collapsable={false}>
@@ -220,6 +216,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
220216
<AndroidDrawerLayoutNativeComponent
221217
{...props}
222218
ref={this._nativeRef}
219+
drawerBackgroundColor={drawerBackgroundColor}
223220
drawerWidth={this.props.drawerWidth}
224221
drawerPosition={this.props.drawerPosition}
225222
drawerLockMode={this.props.drawerLockMode}

Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ exports[`<DrawerLayoutAndroid /> should render as expected: should deep render w
106106

107107
exports[`<DrawerLayoutAndroid /> should render as expected: should shallow render as <DrawerLayoutAndroid /> when mocked 1`] = `
108108
<DrawerLayoutAndroid
109-
drawerBackgroundColor="white"
110109
drawerPosition="left"
111110
drawerWidth={300}
112111
renderNavigationView={[Function]}
@@ -115,7 +114,6 @@ exports[`<DrawerLayoutAndroid /> should render as expected: should shallow rende
115114

116115
exports[`<DrawerLayoutAndroid /> should render as expected: should shallow render as <DrawerLayoutAndroid /> when not mocked 1`] = `
117116
<DrawerLayoutAndroid
118-
drawerBackgroundColor="white"
119117
drawerPosition="left"
120118
drawerWidth={300}
121119
renderNavigationView={[Function]}

0 commit comments

Comments
 (0)