Skip to content

Commit 6632e8a

Browse files
wonderlulazizbecha
authored andcommitted
feat: react-native-reanimated as peer dependency (callstack#4912)
* feat: reanimated as peer dependency
1 parent b502e74 commit 6632e8a

8 files changed

Lines changed: 87 additions & 134 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.

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
@@ -97,7 +97,9 @@
9797
"react-dom": "19.2.3",
9898
"react-native": "0.85.3",
9999
"react-native-builder-bob": "^0.21.3",
100+
"react-native-reanimated": "4.3.1",
100101
"react-native-safe-area-context": "5.7.0",
102+
"react-native-worklets": "0.8.3",
101103
"react-test-renderer": "19.2.3",
102104
"release-it": "^13.4.0",
103105
"rimraf": "^3.0.2",
@@ -106,7 +108,9 @@
106108
"peerDependencies": {
107109
"react": "*",
108110
"react-native": "*",
109-
"react-native-safe-area-context": "*"
111+
"react-native-reanimated": ">=4.3.0",
112+
"react-native-safe-area-context": "*",
113+
"react-native-worklets": ">=0.8.1"
110114
},
111115
"husky": {
112116
"hooks": {
@@ -117,9 +121,10 @@
117121
"jest": {
118122
"preset": "@react-native/jest-preset",
119123
"setupFiles": [
120-
"<rootDir>/testSetup.js"
124+
"<rootDir>/jest/testSetup.js"
121125
],
122126
"setupFilesAfterEnv": [
127+
"<rootDir>/jest/jestSetupAfterEnv.js",
123128
"@testing-library/jest-native/extend-expect"
124129
],
125130
"cacheDirectory": "./cache/jest",

0 commit comments

Comments
 (0)