You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs-reanimated/docs/fundamentals/getting-started.mdx
+21-68Lines changed: 21 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,54 +20,51 @@ With Reanimated, you can easily create smooth animations and interactions that r
20
20
Reanimated 4.x works only with [the React Native New Architecture (Fabric)](https://reactnative.dev/architecture/landing-page).
21
21
If your app still uses the old architecture, you can use Reanimated in version 3 which is still actively maintained.
22
22
23
-
## Quick start
23
+
Alternatively, you can dive into [our examples](https://github.com/software-mansion/react-native-reanimated/tree/3.14.0/apps/common-app/src/examples) on GitHub.
24
+
25
+
## Installation
26
+
27
+
It takes two steps to add Reanimated 4 to an Expo project:
28
+
29
+
### Step 1: Install the package
24
30
25
-
If you don't have an existing project, you can create a new Expo app using a template:
31
+
Install `react-native-reanimated@next` package from npm:
Alternatively, you can dive into [our examples](https://github.com/software-mansion/react-native-reanimated/tree/3.14.0/apps/common-app/src/examples) on GitHub.
41
-
42
-
## Installation
46
+
### Step 2: Rebuild native dependencies
43
47
44
-
It takes three steps to add Reanimated to a project:
45
-
46
-
### Step 1: Install the package
47
-
48
-
Install `react-native-reanimated` package from npm:
48
+
Run prebuild to update the native code in the `ios` and `android` directories.
49
49
50
50
<TabsgroupId="package-managers">
51
-
<TabItemvalue="expo"label="EXPO"default>
52
-
53
-
npx expo install react-native-reanimated
54
-
55
-
</TabItem>
56
51
<TabItemvalue="npm"label="NPM">
57
52
58
-
npm install react-native-reanimated
53
+
npx expo prebuild
59
54
60
55
</TabItem>
61
56
<TabItemvalue="yarn"label="YARN">
62
57
63
-
yarn add react-native-reanimated
58
+
yarn expo prebuild
64
59
65
60
</TabItem>
66
61
</Tabs>
67
62
68
-
### Step 2: Add Reanimated's babel plugin
63
+
And that's it! Reanimated 4 is now configured in your Expo project.
64
+
65
+
### React Native Community CLI
69
66
70
-
Add`react-native-reanimated/plugin` plugin to your `babel.config.js`.
67
+
When using [React Native Community CLI](https://github.com/react-native-community/cli), you also need to manually add the`react-native-reanimated/plugin` plugin to your `babel.config.js`.
71
68
72
69
```js {7}
73
70
module.exports= {
@@ -92,44 +89,15 @@ Add `react-native-reanimated/plugin` plugin to your `babel.config.js`.
92
89
93
90
In short, the Reanimated babel plugin automatically converts special JavaScript functions (called [worklets](/docs/fundamentals/glossary#worklet)) to allow them to be passed and run on the UI thread.
94
91
95
-
To learn more about the plugin head onto to [Reanimated babel plugin](/docs/fundamentals/glossary#reanimated-babel-plugin) section.
96
-
97
-
</details>
98
-
99
-
### Step 3: Wrap metro config with reanimated wrapper (recommended)
100
-
101
-
Wrap your existing Metro configuration in the `metro.config.js` file with the `wrapWithReanimatedMetroConfig` function.
92
+
Since [Expo SDK 50](https://expo.dev/changelog/2024/01-18-sdk-50), the Expo starter template includes the Reanimated babel plugin by default.
Wrapping your Metro configuration with the Reanimated Metro config wrapper will result in displaying improved reanimated errors and warnings with more accurate call stacks. Thanks to this, identifying misuses of the Reanimated API will be much easier than before.
120
-
121
-
To learn more about this feature, head onto to [Accurate Call Stacks](/docs/debugging/accurate-call-stacks).
94
+
To learn more about the plugin head onto to [Reanimated babel plugin](/docs/fundamentals/glossary#reanimated-babel-plugin) section.
122
95
123
96
</details>
124
97
125
-
###Step 4: Clear Metro bundler cache (recommended)
98
+
####Clear Metro bundler cache (recommended)
126
99
127
100
<TabsgroupId="package-managers">
128
-
<TabItemvalue="expo"label="EXPO"default>
129
-
130
-
npx expo start -c
131
-
132
-
</TabItem>
133
101
<TabItemvalue="npm"label="NPM">
134
102
135
103
npm start -- --reset-cache
@@ -142,16 +110,6 @@ To learn more about this feature, head onto to [Accurate Call Stacks](/docs/debu
142
110
</TabItem>
143
111
</Tabs>
144
112
145
-
### Expo development build
146
-
147
-
When using an [Expo development build](https://docs.expo.dev/develop/development-builds/introduction/), run prebuild to update the native code in the `ios` and `android` directories.
148
-
149
-
```bash
150
-
npx expo prebuild
151
-
```
152
-
153
-
### Platform specific setup
154
-
155
113
#### Android
156
114
157
115
No additional steps are necessary.
@@ -171,11 +129,6 @@ For building apps that target web using [react-native-web](https://www.npmjs.com
171
129
To use Reanimated on the web all you need to do is to install and add [`@babel/plugin-proposal-export-namespace-from`](https://babeljs.io/docs/en/babel-plugin-proposal-export-namespace-from) Babel plugin to your `babel.config.js`.
Copy file name to clipboardExpand all lines: packages/docs-reanimated/docs/guides/contributing.mdx
+19-7Lines changed: 19 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,6 @@ The React Native Reanimated repository is a monorepo with the following structur
25
25
```
26
26
├── apps
27
27
│ ├── common-app // shared source code of example apps
28
-
│ ├── paper-example // React Native app wrapper running the Old Architecture for shared examples
29
28
│ ├── fabric-example // React Native app wrapper running the New Architecture for shared examples
30
29
│ ├── macos-example // React Native for MacOS app wrapper for shared example code
31
30
│ ├── next-example // Next.js wrapper for shared example code
@@ -34,6 +33,7 @@ The React Native Reanimated repository is a monorepo with the following structur
34
33
└── packages
35
34
├── docs-reanimated // documentation described further in Helping with documentation
36
35
├── eslint-plugin-reanimated // source of eslint plugin
36
+
├── react-native-worklets // source of worklets package
37
37
└── react-native-reanimated
38
38
├── android // source code of Android native implementation
39
39
├── apple // source code of iOS native implementation
@@ -215,7 +215,19 @@ We have shared code of example app, that is run on different platforms and archi
215
215
-`packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated`– containing source code related to Android native part of Reanimated features
216
216
-`packages/react-native-reanimated/apple`– containing source code related to iOS native part of Reanimated features
217
217
218
-
Our workflow usually starts from editing `apps/common-app/src/examples/EmptyExample.tsx` with testing example for our new feature or a bug. This is the part that we often attach to PR so other developers can test the same use-case (remember not to commit your changes from `EmptyExample` file!). Next, we run the `apps/paper-example` (or `apps/fabric-example` depending on the architecture) app and start development.
218
+
We use two separate example apps depending on the feature or a bug we're currently working on. If the code relates to CSS Animations then we start from editing
This is the part that we often attach to PR so other developers can test the same use-case (remember not to commit your changes from `Playground`/`EmptyExample` file!). Next, we run the `apps/fabric-example` app and start development.
219
231
220
232
:::info
221
233
@@ -228,10 +240,10 @@ If you want to implement a new feature or fix a bug, but still are unsure after
228
240
To start with, let's install all dependencies:
229
241
230
242
1.`yarn && yarn build`
231
-
2.`cd apps/paper-example`
243
+
2.`cd apps/fabric-example`
232
244
3.`yarn start`– make sure to start metro bundler before building the app in Android Studio.
233
245
234
-
and open `react-native-reanimated/apps/paper-example/android` with Android Studio.
246
+
and open `react-native-reanimated/apps/fabric-example/android` with Android Studio.
Copy file name to clipboardExpand all lines: packages/docs-reanimated/docs/guides/supported-properties.mdx
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,3 +182,72 @@ Yoga calculates borders in different ways for numeric values and relative (%) va
182
182
### flexBasis
183
183
184
184
Even though changes of this property are calculated properly during the animation, they aren't applied to the view. Other flex properties, such as `flexGrow` and `flexShrink` work fine, so they could be used for animations.
185
+
186
+
### Animating text shadow styles
187
+
188
+
On the web, all text shadow styles (i.e. `textShadowColor`, `textShadowOffset`, `textShadowRadius`) need to be specified in the animation keyframes to preserve the style during animation.
189
+
190
+
iOS and Android text shadow styles doesn't have this limitations and work as intended.
191
+
192
+
So, for example, if we want to have a shadow color and animate the shadow radius, we can't specify `textShadowColor` just in the element style but we also have to add it to every keyframe of the animation, even though only the `textShadowRadius` is the style we want to animate. Consider this:
193
+
194
+
```jsx
195
+
<Animated.Text
196
+
style={{
197
+
animationName: {
198
+
from: {
199
+
textShadowRadius:8, // while the shadow radius correctly animates from 8 ✅
200
+
},
201
+
to: {
202
+
textShadowRadius:16, // to 16 ✅
203
+
},
204
+
},
205
+
textShadowColor:'red', // 🚨 the shadow color would be overridden in the animation keyframes
206
+
// that means the shadow would be black!
207
+
}}>
208
+
Reanimated
209
+
</Animated.Text>
210
+
```
211
+
212
+
To mitigate this limitation, you need to specify the `textShadowColor` in every keyframe definition:
213
+
214
+
```jsx
215
+
<Animated.Text
216
+
style={{
217
+
animationName: {
218
+
from: {
219
+
textShadowColor:'red', // shadows starts 'red'
220
+
textShadowRadius:8,
221
+
},
222
+
to: {
223
+
textShadowColor:'red', // and keeps being 'red' throughout the animation
224
+
textShadowRadius:16,
225
+
},
226
+
},
227
+
}}>
228
+
Reanimated
229
+
</Animated.Text>
230
+
```
231
+
232
+
<details>
233
+
<summary>Why do I need this?</summary>
234
+
235
+
In CSS the `text-shadow` is a single property but in React Native that's three separate properties for color, offset and radius. Because of that Reanimated has to provide these default values to every keyframe definition:
236
+
237
+
```json
238
+
{
239
+
"textShadowColor": "#000",
240
+
"textShadowRadius": 0,
241
+
"textShadowOffset": { "width": 0, "height": 0 }
242
+
}
243
+
```
244
+
245
+
and the shadow styles aren't inherited from the style object provided to the element. To retain the styles in an animation you need to override these styles to achieve your expected result.
246
+
247
+
</details>
248
+
249
+
### Animating box shadow styles
250
+
251
+
Similarly to the text shadow styles - all shadow styles (i.e. `shadowColor`, `shadowOffset`, `shadowOpacity`, `shadowRadius`) need to be specified in the animation keyframes to preserve the style during animation on the Web. Keep in mind that `shadowOffset`, `shadowOpacity`, `shadowRadius` style properties [aren't implemented on Android in React Native](https://reactnative.dev/docs/shadow-props#props) so they also can't be animated.
252
+
253
+
We highly recommend to use [the `boxShadow` property](https://reactnative.dev/blog/2024/10/23/release-0.76-new-architecture#boxshadow) which doesn't have this limitation and also works on Android.
0 commit comments