diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 2c1e970ca5f..3f7866b5e92 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -288,7 +288,10 @@ class DrawerLayoutAndroid extends React.Component { /** * Closing and opening example - * Note: To access the drawer you have to give it a ref. Refs do not work on stateless components + * Note: To access the drawer you have to give it a ref + * + * Class component: + * * render () { * this.openDrawer = () => { * this.refs.DRAWER.openDrawer() @@ -298,9 +301,25 @@ class DrawerLayoutAndroid extends React.Component { * } * return ( * + * {children} * * ) * } + * + * Function component: + * + * const drawerRef = useRef() + * const openDrawer = () => { + * drawerRef.current.openDrawer() + * } + * const closeDrawer = () => { + * drawerRef.current.closeDrawer() + * } + * return ( + * + * {children} + * + * ) */ _getDrawerLayoutHandle() { return ReactNative.findNodeHandle(this._nativeRef.current);