Skip to content

Commit 2b97cde

Browse files
committed
Update drawer layout docs
1 parent 7f13def commit 2b97cde

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

versioned_docs/version-7.x/drawer-layout.md

+10-29
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: React Native Drawer Layout
44
sidebar_label: Drawer Layout
55
---
66

7-
A cross-platform Drawer component for React Native implemented using [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/).
7+
A cross-platform Drawer component for React Native implemented using [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) on native platforms and CSS transitions on Web.
88

99
<video playsInline autoPlay muted loop>
1010
<source src="/assets/7.x/drawer-layout.mp4" />
@@ -55,7 +55,7 @@ Then, you need to install and configure the libraries that are required by the d
5555
import './gesture-handler';
5656
```
5757

58-
Since the drawer layout doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
58+
Since the drawer layout doesn't use `react-native-gesture-handler` on Web, this avoids unnecessarily increasing the bundle size.
5959

6060
:::warning
6161

@@ -106,7 +106,7 @@ The package exports a `Drawer` component which is the one you'd use to render th
106106

107107
### `Drawer`
108108

109-
Component responsible for rendering a drawer with animations and gestures.
109+
Component is responsible for rendering a drawer sidebar with animations and gestures.
110110

111111
#### Drawer Props
112112

@@ -212,7 +212,7 @@ Content that the drawer should wrap.
212212

213213
### `useDrawerProgress`
214214

215-
The `useDrawerProgress` hook returns a Reanimated SharedValue (with modern implementation) or Reanimated Node (with legacy implementation) which represents the progress of the drawer. It can be used to animate the content of the screen.
215+
The `useDrawerProgress` hook returns a Reanimated `SharedValue` which represents the progress of the drawer. It can be used to animate the content of the screen.
216216

217217
Example with modern implementation:
218218

@@ -239,31 +239,6 @@ function MyComponent() {
239239
}
240240
```
241241

242-
Example with legacy implementation:
243-
244-
```js
245-
import { Animated } from 'react-native-reanimated';
246-
import { useDrawerProgress } from 'react-native-drawer-layout';
247-
248-
// ...
249-
250-
function MyComponent() {
251-
const progress = useDrawerProgress();
252-
253-
// If you are on react-native-reanimated 1.x, use `Animated.interpolate` instead of `Animated.interpolateNode`
254-
const translateX = Animated.interpolateNode(progress, {
255-
inputRange: [0, 1],
256-
outputRange: [-100, 0],
257-
});
258-
259-
return (
260-
<Animated.View style={{ transform: [{ translateX }] }}>
261-
{/* ... */}
262-
</Animated.View>
263-
);
264-
}
265-
```
266-
267242
If you are using class components, you can use the `DrawerProgressContext` to get the progress value.
268243

269244
```js
@@ -281,3 +256,9 @@ class MyComponent extends React.Component {
281256
}
282257
}
283258
```
259+
260+
:::warning
261+
262+
The `useDrawerProgress` hook (or `DrawerProgressContext`) will return a mock value on Web since Reanimated is not used on Web. The mock value can only represent the open state of the drawer (`0` when closed, `1` when open), and not the progress of the drawer.
263+
264+
:::

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,13 @@ export default function App() {
762762
</TabItem>
763763
</Tabs>
764764

765-
This hook is not supported on Web.
765+
If you are using class components, you can use the `DrawerProgressContext` to get the progress value.
766+
767+
:::warning
768+
769+
The `useDrawerProgress` hook (or `DrawerProgressContext`) will return a mock value on Web since Reanimated is not used on Web. The mock value can only represent the open state of the drawer (`0` when closed, `1` when open), and not the progress of the drawer.
770+
771+
:::
766772

767773
#### `useDrawerStatus`
768774

0 commit comments

Comments
 (0)