Skip to content

Commit c5f5f64

Browse files
committed
Update stack docs for removal of Animated
1 parent afe3b88 commit c5f5f64

File tree

4 files changed

+765
-782
lines changed

4 files changed

+765
-782
lines changed

docs/stack-navigator.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ To use this navigator, you need to install [`@react-navigation/stack`](https://g
1414
yarn add @react-navigation/native@next @react-navigation/stack@next @react-native-community/masked-view
1515
```
1616

17-
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler), [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated), [`react-native-screens`](https://github.com/kmagiera/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
17+
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler), [`react-native-screens`](https://github.com/kmagiera/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
1818

1919
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
2020

2121
```sh
22-
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context
22+
expo install react-native-gesture-handler react-native-screens react-native-safe-area-context
2323
```
2424

2525
If you are not using Expo, run the following:
2626

2727
```sh
28-
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context
28+
yarn add react-native-gesture-handler react-native-screens react-native-safe-area-context
2929
```
3030

3131
If you are using Expo, you are done. Otherwise, continue to the next steps.
@@ -77,7 +77,7 @@ public class MainActivity extends ReactActivity {
7777
Then add the following at the top of your entry file, such as `index.js` or `App.js`:
7878

7979
```js
80-
import 'react-native-gesture-handler'
80+
import 'react-native-gesture-handler';
8181
```
8282

8383
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
@@ -468,9 +468,9 @@ Stack Navigator exposes various options to configure the transition animation wh
468468
The function receives the following properties in it's argument:
469469

470470
- `current` - Values for the current screen:
471-
- `progress` - Renimated node representing the progress value of the current screen.
471+
- `progress` - Animated node representing the progress value of the current screen.
472472
- `next` - Values for the current screen the screen after this one in the stack. This can be `undefined` in case the screen animating is the last one.
473-
- `progress` - Renimated node representing the progress value of the next screen.
473+
- `progress` - Animated node representing the progress value of the next screen.
474474
- `index` - The index of the card in the stack.
475475
- `closing` - Animated node representing whether the card is closing. `1` when closing, `0` if not.
476476
- `layouts` - Layout measurements for various items we use for animation.
@@ -481,14 +481,7 @@ Stack Navigator exposes various options to configure the transition animation wh
481481
```js
482482
const forFade = ({ current, closing }) => ({
483483
cardStyle: {
484-
opacity: cond(
485-
closing,
486-
current.progress,
487-
interpolate(current.progress, {
488-
inputRange: [0, 0.5, 0.9, 1],
489-
outputRange: [0, 0.25, 0.7, 1],
490-
})
491-
),
484+
opacity: current.progress,
492485
},
493486
});
494487
```
@@ -513,9 +506,9 @@ Stack Navigator exposes various options to configure the transition animation wh
513506
The function receives the following properties in it's argument:
514507

515508
- `current` - Values for the current screen (the screen which owns this header).
516-
- `progress` - Renimated node representing the progress value of the current screen.
509+
- `progress` - Animated node representing the progress value of the current screen.
517510
- `next` - Values for the current screen the screen after this one in the stack. This can be `undefined` in case the screen animating is the last one.
518-
- `progress` - Renimated node representing the progress value of the next screen.
511+
- `progress` - Animated node representing the progress value of the next screen.
519512
- `layouts` - Layout measurements for various items we use for animation. Each layout object contain `height` and `width` properties.
520513
- `screen` - Layout of the whole screen.
521514
- `title` - Layout of the title element. Might be `undefined` when not rendering a title.
@@ -525,13 +518,13 @@ Stack Navigator exposes various options to configure the transition animation wh
525518

526519
```js
527520
const forFade = ({ current, next }) => {
528-
const opacity = interpolate(
529-
add(current.progress, next ? next.progress : 0),
530-
{
531-
inputRange: [0, 1, 2],
532-
outputRange: [0, 1, 0],
533-
}
534-
);
521+
const opacity = Animated.add(
522+
current.progress,
523+
next ? next.progress : 0
524+
).interpolate({
525+
inputRange: [0, 1, 2],
526+
outputRange: [0, 1, 0],
527+
});
535528

536529
return {
537530
leftButtonStyle: { opacity },

0 commit comments

Comments
 (0)