From 305b0a28142414d559d2d08795a5963716dc4b0f Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 8 Aug 2019 11:49:19 -0700 Subject: [PATCH] DrawerLayoutAndroid drawerPosition now expects a string, number is deprecated Summary: The native change to support strings was made in D15912607 on June 21st. Migrating the JS callsites now to start passing strings instead of the constants. Reviewed By: zackargyle, mdvacca Differential Revision: D16703569 fbshipit-source-id: cb1d8698df55d2961cde1e2b1fbfcba086a03bb2 --- .../AndroidDrawerLayoutNativeComponent.js | 2 +- .../DrawerAndroid/DrawerLayoutAndroid.android.js | 16 +++++++++------- .../__tests__/DrawerAndroid-test.js | 8 ++++---- .../__snapshots__/DrawerAndroid-test.js.snap | 8 ++++---- RNTester/js/RNTesterApp.android.js | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js index 55ef782ad9b..9507b691b58 100644 --- a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +++ b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js @@ -60,7 +60,7 @@ type NativeProps = $ReadOnly<{| /** * Specifies the side of the screen from which the drawer will slide in. */ - drawerPosition: ?Int32, + drawerPosition?: WithDefault<'left' | 'right', 'left'>, /** * Specifies the width of the drawer, more precisely the width of the view that be pulled in diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index f80846d25a0..5807013f55e 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -12,15 +12,11 @@ const Platform = require('../../Utilities/Platform'); const React = require('react'); -const ReactNative = require('../../Renderer/shims/ReactNative'); const StatusBar = require('../StatusBar/StatusBar'); const StyleSheet = require('../../StyleSheet/StyleSheet'); -const UIManager = require('../../ReactNative/UIManager'); const View = require('../View/View'); const nullthrows = require('nullthrows'); -const DrawerConsts = UIManager.getViewManagerConfig('AndroidDrawerLayout') - .Constants; const dismissKeyboard = require('../../Utilities/dismissKeyboard'); import AndroidDrawerLayoutNativeComponent, { Commands, @@ -67,7 +63,7 @@ type Props = $ReadOnly<{| /** * Specifies the side of the screen from which the drawer will slide in. */ - drawerPosition: ?number, + drawerPosition: ?('left' | 'right'), /** * Specifies the width of the drawer, more precisely the width of the view that be pulled in @@ -148,7 +144,7 @@ type State = {| * return ( * navigationView}> * * Hello @@ -160,7 +156,13 @@ type State = {| * ``` */ class DrawerLayoutAndroid extends React.Component { - static positions = DrawerConsts.DrawerPosition; + static get positions(): mixed { + console.warn( + 'Setting DrawerLayoutAndroid drawerPosition using `DrawerLayoutAndroid.positions` is deprecated. Instead pass the string value "left" or "right"', + ); + + return {Left: 'left', Right: 'right'}; + } static defaultProps = { drawerBackgroundColor: 'white', }; diff --git a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js index 514edf85cc4..91c800f59c3 100644 --- a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js +++ b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js @@ -25,7 +25,7 @@ describe('', () => { const instance = render.create( } />, ); @@ -36,7 +36,7 @@ describe('', () => { const output = render.shallow( } />, ); @@ -49,7 +49,7 @@ describe('', () => { const output = render.shallow( } />, ); @@ -62,7 +62,7 @@ describe('', () => { const instance = render.create( } />, ); diff --git a/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap b/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap index f647438e3a1..88f8eeca171 100644 --- a/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap +++ b/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap @@ -3,7 +3,7 @@ exports[` should render as when mocked 1`] = ` should render as when moc exports[` should render as when not mocked 1`] = ` should render as when not exports[` should shallow render as when mocked 1`] = ` @@ -116,7 +116,7 @@ exports[` should shallow render as exports[` should shallow render as when not mocked 1`] = ` diff --git a/RNTester/js/RNTesterApp.android.js b/RNTester/js/RNTesterApp.android.js index a7c79047de9..f23e5093a21 100644 --- a/RNTester/js/RNTesterApp.android.js +++ b/RNTester/js/RNTesterApp.android.js @@ -105,7 +105,7 @@ class RNTesterApp extends React.Component { } return ( {