Skip to content

Commit fdf6ef7

Browse files
committed
Remove progress prop from drawerContent for 6.x
1 parent 6289b97 commit fdf6ef7

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

static/examples/6.x/animated-drawer-content.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DrawerContentScrollView,
77
DrawerItemList,
88
DrawerItem,
9+
useDrawerProgress,
910
} from '@react-navigation/drawer';
1011
import Animated from 'react-native-reanimated';
1112

@@ -25,16 +26,18 @@ function Article() {
2526
);
2627
}
2728

28-
function CustomDrawerContent({ progress, ...rest }) {
29-
const translateX = Animated.interpolate(progress, {
29+
function CustomDrawerContent(props) {
30+
const progress = useDrawerProgress();
31+
32+
const translateX = Animated.interpolateNode(progress, {
3033
inputRange: [0, 1],
3134
outputRange: [-100, 0],
3235
});
3336

3437
return (
35-
<DrawerContentScrollView {...rest}>
38+
<DrawerContentScrollView {...props}>
3639
<Animated.View style={{ transform: [{ translateX }] }}>
37-
<DrawerItemList {...rest} />
40+
<DrawerItemList {...props} />
3841
<DrawerItem label="Help" onPress={() => alert('Link to help')} />
3942
</Animated.View>
4043
</DrawerContentScrollView>

versioned_docs/version-6.x/drawer-navigator.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ The content component receives following props by default:
122122
- `state` - The [navigation state](navigation-state.md) of the navigator.
123123
- `navigation` - The navigation object for the navigator.
124124
- `descriptors` - An descriptor object containing options for the drawer screens. The options can be accessed at `descriptors[route.key].options`.
125-
- `progress` - Reanimated Node that represents the animated position of the drawer (0 is closed; 1 is open).
126125

127126
##### Providing a custom `drawerContent`
128127

@@ -197,7 +196,7 @@ function CustomDrawerContent(props) {
197196
}
198197
```
199198

200-
The `progress` object is a Reanimated `Node` if you're using Reanimated 1 (see [`useLegacyImplementation`](#uselegacyimplementation)), otherwise a `SharedValue`.
199+
The `progress` object is a Reanimated `Node` if you're using Reanimated 1 (see [`useLegacyImplementation`](#uselegacyimplementation)), otherwise a `SharedValue`. It represents the animated position of the drawer (0 is closed; 1 is open).
201200

202201
Note that you **cannot** use the `useNavigation` hook inside the `drawerContent` since `useNavigation` is only available inside screens. You get a `navigation` prop for your `drawerContent` which you can use instead:
203202

versioned_docs/version-6.x/upgrading-from-5.x.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,24 @@ The following options have been moved and renamed:
676676

677677
The old options will still keep working with a deprecation warning. To avoid the deprecation warning, move these to `screenOptions`.
678678

679+
### The `drawerContent` prop no longer receives `progress` in its argument
680+
681+
The callback passed to `drawerContent` no longer receives the animated `progress` value in its argument. Instead, you can use the `useDrawerProgress` hook to get the current progress value.
682+
683+
```js
684+
function CustomDrawerContent(props) {
685+
const progress = useDrawerProgress();
686+
687+
// ...
688+
}
689+
690+
// ...
691+
692+
<Drawer.Navigator drawerContent={(props) => <CustomDrawerContent {...props} />}>
693+
```
694+
695+
The `useDrawerProgress` hook returns a Reanimated `Node` or Reanimated `SharedValue` depending on the implementation used.
696+
679697
### The `lazy` prop is moved to `lazy` option for per-screen configuration for drawer
680698

681699
Similar to bottom tabs, the `lazy` prop is now moved to `options` for drawer.

0 commit comments

Comments
 (0)