Skip to content

Commit 888f3a6

Browse files
docs: apply feedback
1 parent 4d53ac5 commit 888f3a6

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

versioned_docs/version-6.x/shared-element-transitions.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# Animating elements between screens
22

3-
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/api/sharedElementTransitions) and it's implemented in the native stack with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
3+
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/api/sharedElementTransitions) and it's implemented in the [`@react-navigation/native-stack`](<(/docs/native-stack-navigator)>) with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
44

5-
Before continuing, make sure to install and configure [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation).
6-
7-
> Note: Shared Element Transitions require React Native Reanimated v3.0.0 or higher, and as of writing this guide, it's considered an experimental feature not recommended for production use.
5+
> Note: As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
86
97
<div style={{ display: 'flex', margin: '16px 0' }}>
108
<video playsInline autoPlay muted loop>
119
<source src="/assets/shared-element-transitions/shared-element-transitions.mp4" />
1210
</video>
1311
</div>
1412

13+
## Pre-requisites
14+
15+
Before continuing this guide make sure your app meets these criteria:
16+
17+
- You are using [`@react-navigation/native-stack`](/docs/native-stack-navigator). The Shared Element Transitions feature isn't supported in JS-based [`@react-navigation/stack`](/docs/stack-navigator).
18+
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation) **v3.0.0 or higher** installed and configured.
19+
1520
## Minimal example
1621

17-
To create a shared transition, simply assign the same `sharedTransitionTag` to elements on different screens in a native stack. This prop is a string that has to be unique in the context of a single screen, but has to match elements between screens. Similarly to the [`key`](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) property, which tells React which element in the list is which, `sharedElementTag` allows Reanimated to identify and animate elements. Components that you'd like to animate have to be `Animated` versions imported from `react-native-reanimated`. The animation will start automatically when you navigate between screens.
22+
To create a shared transition:
23+
24+
1. Use `Animated` components imported from `react-native-reanimated`.
25+
2. Assign the same `sharedTransitionTag` to elements on different screens.
26+
3. Navigate between screens. The transition will start automatically.
1827

1928
```jsx
2029
import * as React from 'react';
@@ -24,6 +33,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
2433

2534
import Animated from 'react-native-reanimated';
2635

36+
// highlight-next-line
2737
const Stack = createNativeStackNavigator();
2838

2939
function HomeScreen({ navigation }) {
@@ -76,6 +86,8 @@ const styles = StyleSheet.create({
7686
});
7787
```
7888

89+
`sharedTransitionTag` is a string that has to be unique in the context of a single screen, but has to match elements between screens. This prop allows Reanimated to identify and animate the elements, similarly to the [`key`](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) property, which tells React which element in the list is which.
90+
7991
## Customizing the transition
8092

8193
By default, the transition animates the `width`, `height`, `originX`, `originY` and `transform` properties using `withTiming` with a 500 ms duration. You can easily customize `width`, `height`, `originX`, and `originY` props. Customizing `transform` is also possible but it's far beyond the scope of this guide.
@@ -115,6 +127,6 @@ You can find a full Shared Element Transitions reference in the [React Native Re
115127

116128
## Alternatives
117129

118-
Alternatively, you can use [`react-native-shared-element`](https://github.com/IjzerenHein/react-native-shared-element) library with a [React Navigation binding](https://github.com/IjzerenHein/react-navigation-shared-element) which implements Shared Element Transitions in a JS-based Stack navigator. This solution, however, isn't actively maintained.
130+
Alternatively, you can use [`react-native-shared-element`](https://github.com/IjzerenHein/react-native-shared-element) library with a [React Navigation binding](https://github.com/IjzerenHein/react-navigation-shared-element) which implements Shared Element Transitions in a JS-based `@react-navigation/stack` navigator. This solution, however, isn't actively maintained.
119131

120132
The [`react-native-navigation`](https://github.com/wix/react-native-navigation) also comes with support for Shared Element Transitions. You can read more about it [here](https://wix.github.io/react-native-navigation/docs/style-animations#shared-element-transitions).

versioned_docs/version-7.x/shared-element-transitions.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# Animating elements between screens
22

3-
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/api/sharedElementTransitions) and it's implemented in the native stack with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
3+
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/api/sharedElementTransitions) and it's implemented in the [`@react-navigation/native-stack`](<(/docs/native-stack-navigator)>) with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
44

5-
Before continuing, make sure to install and configure [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation).
6-
7-
> Note: Shared Element Transitions require React Native Reanimated v3.0.0 or higher, and as of writing this guide, it's considered an experimental feature not recommended for production use.
5+
> Note: As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
86
97
<div style={{ display: 'flex', margin: '16px 0' }}>
108
<video playsInline autoPlay muted loop>
119
<source src="/assets/shared-element-transitions/shared-element-transitions.mp4" />
1210
</video>
1311
</div>
1412

13+
## Pre-requisites
14+
15+
Before continuing this guide make sure your app meets these criteria:
16+
17+
- You are using [`@react-navigation/native-stack`](/docs/native-stack-navigator). The Shared Element Transitions feature isn't supported in JS-based [`@react-navigation/stack`](/docs/stack-navigator).
18+
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation) **v3.0.0 or higher** installed and configured.
19+
1520
## Minimal example
1621

17-
To create a shared transition, simply assign the same `sharedTransitionTag` to elements on different screens in a native stack. This prop is a string that has to be unique in the context of a single screen, but has to match elements between screens. Similarly to the [`key`](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) property, which tells React which element in the list is which, `sharedElementTag` allows Reanimated to identify and animate elements. Components that you'd like to animate have to be `Animated` versions imported from `react-native-reanimated`. The animation will start automatically when you navigate between screens.
22+
To create a shared transition:
23+
24+
1. Use `Animated` components imported from `react-native-reanimated`.
25+
2. Assign the same `sharedTransitionTag` to elements on different screens.
26+
3. Navigate between screens. The transition will start automatically.
1827

1928
```jsx
2029
import * as React from 'react';
@@ -24,6 +33,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
2433

2534
import Animated from 'react-native-reanimated';
2635

36+
// highlight-next-line
2737
const Stack = createNativeStackNavigator();
2838

2939
function HomeScreen({ navigation }) {
@@ -76,6 +86,8 @@ const styles = StyleSheet.create({
7686
});
7787
```
7888

89+
`sharedTransitionTag` is a string that has to be unique in the context of a single screen, but has to match elements between screens. This prop allows Reanimated to identify and animate the elements, similarly to the [`key`](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) property, which tells React which element in the list is which.
90+
7991
## Customizing the transition
8092

8193
By default, the transition animates the `width`, `height`, `originX`, `originY` and `transform` properties using `withTiming` with a 500 ms duration. You can easily customize `width`, `height`, `originX`, and `originY` props. Customizing `transform` is also possible but it's far beyond the scope of this guide.
@@ -115,6 +127,6 @@ You can find a full Shared Element Transitions reference in the [React Native Re
115127

116128
## Alternatives
117129

118-
Alternatively, you can use [`react-native-shared-element`](https://github.com/IjzerenHein/react-native-shared-element) library with a [React Navigation binding](https://github.com/IjzerenHein/react-navigation-shared-element) which implements Shared Element Transitions in a JS-based Stack navigator. This solution, however, isn't actively maintained.
130+
Alternatively, you can use [`react-native-shared-element`](https://github.com/IjzerenHein/react-native-shared-element) library with a [React Navigation binding](https://github.com/IjzerenHein/react-navigation-shared-element) which implements Shared Element Transitions in a JS-based `@react-navigation/stack` navigator. This solution, however, isn't actively maintained.
119131

120132
The [`react-native-navigation`](https://github.com/wix/react-native-navigation) also comes with support for Shared Element Transitions. You can read more about it [here](https://wix.github.io/react-native-navigation/docs/style-animations#shared-element-transitions).

0 commit comments

Comments
 (0)