Skip to content

Commit 9ded0ac

Browse files
authored
feat: react-native-reanimated as peer dependency (#4912)
* feat: reanimated as peer dependency
1 parent 2f8b840 commit 9ded0ac

9 files changed

Lines changed: 117 additions & 64 deletions

File tree

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ docs/build/
55
docs/public/
66
docs/static/
77
web-build/
8-
testSetup.js
8+
jest/testSetup.js
99
__fixtures__/
1010

1111
# generated by bob

babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
22
presets: ['module:@react-native/babel-preset'],
3+
plugins: ['react-native-worklets/plugin'],
34
};
Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,54 @@
22
title: Getting Started
33
---
44

5+
import TabItem from '@theme/TabItem';
6+
import Tabs from '@theme/Tabs';
7+
58
# Getting Started
69

710
## Installation
811

9-
- Open a Terminal in your project's folder and run:
12+
Open a Terminal in your project's folder and install the library:
1013

1114
```bash npm2yarn
1215
npm install react-native-paper
1316
```
1417

15-
- From `v5` there is a need to install [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) for handling safe area.
18+
React Native Paper uses [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) for handling safe area, [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/) and [react-native-worklets](https://docs.swmansion.com/react-native-worklets/) for animations.
1619

17-
```bash npm2yarn
18-
npm install react-native-safe-area-context
20+
<Tabs groupId="expo-vs-cli">
21+
<TabItem value="expo" label="Expo" default>
22+
23+
```bash
24+
npx expo install react-native-safe-area-context react-native-reanimated react-native-worklets
1925
```
2026

21-
Additionaly for `iOS` platform there is a requirement to link the native parts of the library:
27+
Minimum requirements:
2228

23-
```bash
24-
npx pod-install
29+
- `react-native-reanimated` **≥ 4.3.0**
30+
- `react-native-worklets` **≥ 0.8.1**
31+
- `react-native-safe-area-context` — version compatible with your React Native toolchain.
32+
33+
Follow the [React Native Reanimated installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/).
34+
35+
If you use Expo, you don't need to install vector icons - those are the part of the expo package. However, if you have a `babel.config.js` or `.babelrc` file, make sure that it includes `babel-preset-expo`.
36+
37+
</TabItem>
38+
<TabItem value="community-cli" label="Community CLI">
39+
40+
```bash npm2yarn
41+
npm install react-native-safe-area-context react-native-reanimated react-native-worklets
2542
```
2643

27-
- If you're on a vanilla React Native project, you also need to install and link [@react-native-vector-icons/material-design-icons](https://github.com/oblador/react-native-vector-icons).
44+
Minimum requirements:
45+
46+
- `react-native-reanimated` **≥ 4.3.0**
47+
- `react-native-worklets` **≥ 0.8.1**
48+
- `react-native-safe-area-context` — version compatible with your React Native toolchain.
49+
50+
Follow the [React Native Reanimated installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/).
51+
52+
If you're on a vanilla React Native project, you also need to install and link [@react-native-vector-icons/material-design-icons](https://github.com/oblador/react-native-vector-icons).
2853

2954
Specifically `MaterialDesignIcons` icon pack needs to be included in the project, because some components use those internally (e.g. `AppBar.BackAction` on Android).
3055

@@ -36,11 +61,12 @@ npm install @react-native-vector-icons/material-design-icons
3661
The `react-native-vector-icons` library requires some additional setup steps for each platform. To ensure proper use of icon fonts, please follow their [installation guide](https://github.com/oblador/react-native-vector-icons?tab=readme-ov-file#setup).
3762
:::
3863

39-
If you use Expo, you don't need to install vector icons - those are the part of the expo package. However, if you have a `babel.config.js` or `.babelrc` file, make sure that it includes `babel-preset-expo`.
40-
4164
:::info
4265
If you don't want to install vector icons, you can use [babel-plugin-optional-require](https://github.com/satya164/babel-plugin-optional-require) to opt-out.
43-
:::note
66+
:::
67+
68+
</TabItem>
69+
</Tabs>
4470

4571
### Bundle size optimization
4672

docs/docs/guides/03-icons.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import IconsList from '@site/src/components/IconsList.tsx';
1010

1111
## Configuring icons
1212

13-
Many of the components require the [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons) library to render correctly. If you're using Expo, you don't need to do anything extra, but if it's a vanilla React Native project, you need to link the library as described in the [getting started guide](./01-getting-started.md).
13+
Many of the components require the [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons) library to render correctly. If you're using Expo, you don't need to do anything extra, but if it's a vanilla React Native project, you need to link the library as described in the [getting started guide](./01-getting-started.mdx).
1414

1515
:::note
1616
If you opted out of vector icons support using [babel-plugin-optional-require](https://github.com/satya164/babel-plugin-optional-require), you won't be able to use icon names for the icon prop. Some components may not look correct without vector icons and might need extra configuration.

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"react-native": "0.81.4",
3737
"react-native-gesture-handler": "~2.28.0",
3838
"react-native-monorepo-config": "^0.1.6",
39-
"react-native-reanimated": "~4.1.1",
39+
"react-native-reanimated": "^4.3.0",
4040
"react-native-safe-area-context": "~5.6.0",
4141
"react-native-screens": "~4.16.0",
4242
"react-native-web": "^0.21.0",
43-
"react-native-worklets": "0.5.1",
43+
"react-native-worklets": "^0.8.1",
4444
"typeface-roboto": "^1.1.13"
4545
},
4646
"devDependencies": {

jest/jestSetupAfterEnv.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { setUpTests } from 'react-native-reanimated';
2+
3+
setUpTests();

testSetup.js renamed to jest/testSetup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ jest.useFakeTimers();
44

55
jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);
66

7+
jest.mock('react-native-worklets', () =>
8+
require('react-native-worklets/lib/module/mock')
9+
);
10+
711
jest.mock('@react-native-vector-icons/material-design-icons', () => {
812
const React = require('react');
913
const { Text } = require('react-native');
@@ -128,4 +132,4 @@ jest.mock('react-native/Libraries/Utilities/BackHandler', () => {
128132
},
129133
},
130134
};
131-
});
135+
});

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
"react-dom": "18.3.1",
9797
"react-native": "0.82.1",
9898
"react-native-builder-bob": "^0.21.3",
99+
"react-native-reanimated": "^4.3.0",
99100
"react-native-safe-area-context": "5.5.2",
101+
"react-native-worklets": "^0.8.1",
100102
"react-test-renderer": "19.1.1",
101103
"release-it": "^13.4.0",
102104
"rimraf": "^3.0.2",
@@ -105,7 +107,9 @@
105107
"peerDependencies": {
106108
"react": "*",
107109
"react-native": "*",
108-
"react-native-safe-area-context": "*"
110+
"react-native-reanimated": ">=4.3.0",
111+
"react-native-safe-area-context": "*",
112+
"react-native-worklets": ">=0.8.1"
109113
},
110114
"husky": {
111115
"hooks": {
@@ -116,9 +120,10 @@
116120
"jest": {
117121
"preset": "react-native",
118122
"setupFiles": [
119-
"<rootDir>/testSetup.js"
123+
"<rootDir>/jest/testSetup.js"
120124
],
121125
"setupFilesAfterEnv": [
126+
"<rootDir>/jest/jestSetupAfterEnv.js",
122127
"@testing-library/jest-native/extend-expect"
123128
],
124129
"cacheDirectory": "./cache/jest",

0 commit comments

Comments
 (0)