Skip to content

Commit 77fb950

Browse files
committed
docs: update the guides for latest React Native
1 parent caa63a7 commit 77fb950

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

docs/pages/2.getting-started.md

+28-31
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,53 @@ react-native link react-native-vector-icons
1919

2020
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.
2121

22-
If you use CRNA or Expo, you don't need to install vector icons. But you will need to make sure that your `.babelrc` includes `babel-preset-expo`:
22+
If you use Expo, you don't need to install vector icons. But if you have a `babel.config.js` or `.babelrc` file, make sure that it includes `babel-preset-expo`.
2323

24-
```json
25-
{
26-
"presets": ["babel-preset-expo"]
27-
}
28-
```
29-
30-
To get smaller bundle size by excluding modules you don't use, you can use our optional babel plugin. The plugin automatically rewrites the import statements so that only the modules you use are imported instead of the whole library. Add `react-native-paper/babel` to the `plugins` section in your `.babelrc` for production environment. It should look like this:
24+
To get smaller bundle size by excluding modules you don't use, you can use our optional babel plugin. The plugin automatically rewrites the import statements so that only the modules you use are imported instead of the whole library. Add `react-native-paper/babel` to the `plugins` section in your `babel.config.js` for production environment. It should look like this:
3125

32-
```json
33-
{
34-
"presets": ["babel-preset-react-native"],
35-
"env": {
36-
"production": {
37-
"plugins": ["react-native-paper/babel"]
38-
}
39-
}
40-
}
26+
```js
27+
module.exports = {
28+
presets: ['module:metro-react-native-babel-preset'],
29+
env: {
30+
production: {
31+
plugins: ['react-native-paper/babel'],
32+
},
33+
},
34+
};
4135
```
4236

43-
If you created your project using CRNA or Expo, it'll look something like this:
37+
If you created your project using Expo, it'll look something like this:
4438

45-
```json
46-
{
47-
"presets": ["babel-preset-expo"],
48-
"env": {
49-
"development": {
50-
"plugins": ["transform-react-jsx-source"]
39+
```js
40+
module.exports = function(api) {
41+
api.cache(true);
42+
return {
43+
presets: ['babel-preset-expo'],
44+
env: {
45+
production: {
46+
plugins: ['react-native-paper/babel'],
47+
},
5148
},
52-
"production": {
53-
"plugins": ["react-native-paper/babel"]
54-
}
55-
}
56-
}
49+
};
50+
};
5751
```
5852

59-
**Note:** The plugin only works if you are importing the library using ES2015 import statements and not with `require`.
53+
The plugin only works if you are importing the library using ES2015 import statements and not with `require`.
54+
55+
**Note:** The above examples are for the latest `react-native` using Babel 7. If you have `react-native <= 0.55`, you'll have a `.babelrc` file instead of a `babel.config.js` file and the content of the file will be different.
6056

6157
If you're using Flow for typechecking your code, you need to add the following under the `[options]` section in your `.flowconfig`:
6258

6359
```ini
6460
module.file_ext=.js
61+
module.file_ext=.native.js
6562
module.file_ext=.android.js
6663
module.file_ext=.ios.js
6764
```
6865

6966
## Usage
7067

71-
Wrap your root component in `Provider` from `react-native-paper`. If you have a vanilla React Native project, it's a good idea to add it in the component which is passed to `AppRegistry.registerComponent`. This will usually be in the `index.js` file. If you have a CRNA or Expo project, you can do this inside the exported component in the `App.js` file.
68+
Wrap your root component in `Provider` from `react-native-paper`. If you have a vanilla React Native project, it's a good idea to add it in the component which is passed to `AppRegistry.registerComponent`. This will usually be in the `index.js` file. If you have an Expo project, you can do this inside the exported component in the `App.js` file.
7269

7370
Example:
7471

docs/pages/4.icons.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Icons
44

55
## Configuring icons
66

7-
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 CRNA or Expo, you don't need to do anything extra, but if it's vanilla React Native project, you need link the library as described in the getting started guide.
7+
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 vanilla React Native project, you need link the library as described in the getting started guide.
88

99
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 anymore. Some components may not look correct without vector icons and might need extra configuration.
1010

0 commit comments

Comments
 (0)