Skip to content

Commit d0ad27c

Browse files
authored
chore: update react-native-vector-icons (#4696)
1 parent 1004de3 commit d0ad27c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+636
-1504
lines changed

.github/workflows/versions.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ jobs:
88
if: ${{ github.event.label.name == 'bug' }}
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: react-navigation/check-versions-action@v1.0.0
11+
- uses: react-navigation/check-versions-action@v1.1.0
1212
with:
1313
github-token: ${{ secrets.GITHUB_TOKEN }}
1414
required-packages: |
15-
react-native
1615
react-native-paper
17-
react-native-vector-icons
1816
optional-packages: |
19-
expo
20-
npm
21-
yarn
17+
@react-native-vector-icons/common
18+
@react-native-vector-icons/material-design-icons

docs/docs/guides/01-getting-started.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ title: Getting Started
66

77
## Installation
88

9-
* Open a Terminal in your project's folder and run:
9+
- Open a Terminal in your project's folder and run:
1010

1111
```bash npm2yarn
1212
npm install react-native-paper
1313
```
1414

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.
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.
1616

1717
```bash npm2yarn
1818
npm install react-native-safe-area-context
@@ -24,19 +24,25 @@ Additionaly for `iOS` platform there is a requirement to link the native parts o
2424
npx pod-install
2525
```
2626

27-
* If you're on a vanilla React Native project, you also need to install and link [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons).
27+
- If you're on a vanilla React Native project, you also need to install and link [@react-native-vector-icons/common](https://github.com/oblador/react-native-vector-icons).
2828

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

3131
```bash npm2yarn
32-
npm install react-native-vector-icons
32+
npm install @react-native-vector-icons/common @react-native-vector-icons/material-design-icons
3333
```
3434

35-
The library has specified dedicated steps for each platform. Please follow their [installation guide](https://github.com/oblador/react-native-vector-icons#installation) in order to properly use icon fonts.
35+
:::note
36+
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).
37+
:::
3638

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+
41+
:::info
3742
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
3844

39-
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`.
45+
### Bundle size optimization
4046

4147
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:
4248

@@ -54,7 +60,7 @@ module.exports = {
5460
If you created your project using Expo, it'll look something like this:
5561

5662
```js
57-
module.exports = function(api) {
63+
module.exports = function (api) {
5864
api.cache(true);
5965
return {
6066
presets: ['babel-preset-expo'],
@@ -136,7 +142,10 @@ Example:
136142

137143
```js
138144
import * as React from 'react';
139-
import { MD3LightTheme as DefaultTheme, PaperProvider } from 'react-native-paper';
145+
import {
146+
MD3LightTheme as DefaultTheme,
147+
PaperProvider,
148+
} from 'react-native-paper';
140149
import App from './src/App';
141150

142151
const theme = {

docs/docs/guides/03-icons.mdx

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@ import IconsList from '@site/src/components/IconsList.tsx';
88

99
## Configuring icons
1010

11-
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.
11+
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).
1212

13+
:::note
1314
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.
15+
:::
1416

1517
## Using the `icon` prop
1618

1719
Many components such as `Button` accept an `icon` prop which is used to display an icon. The `icon` prop supports the following types of values:
1820

1921
### 1. An icon name
2022

21-
You can pass the name of an icon from [`MaterialCommunityIcons`](https://materialdesignicons.com). This will use the [`react-native-vector-icons`](https://github.com/oblador/react-native-vector-icons) library to display the icon.
23+
You can pass the name of an icon from [`MaterialDesignIcons`](https://pictogrammers.com/library/mdi/). This will use the [`@react-native-vector-icons/material-design-icons`](https://github.com/oblador/react-native-vector-icons/tree/master/packages/material-design-icons) library to display the icon.
2224

2325
Example:
2426

2527
```js
26-
<Button icon="camera">
27-
Press me
28-
</Button>
28+
<Button icon="camera">Press me</Button>
2929
```
3030

31-
<details><summary>See the list of supported icons</summary>
31+
<details>
32+
<summary>See the list of supported icons</summary>
3233
<IconsList />
3334
</details>
3435

@@ -39,17 +40,17 @@ You can pass an image source, such as an object of shape `{ uri: 'https://path.t
3940
Remote image:
4041

4142
```js
42-
<Button icon={{ uri: 'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400' }}>
43+
<Button
44+
icon={{ uri: 'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400' }}
45+
>
4346
Press me
4447
</Button>
4548
```
4649

4750
Local image:
4851

4952
```js
50-
<Button icon={require('../assets/chameleon.jpg')}>
51-
Press me
52-
</Button>
53+
<Button icon={require('../assets/chameleon.jpg')}>Press me</Button>
5354
```
5455

5556
### 3. A render function
@@ -73,22 +74,22 @@ Example:
7374

7475
### 4. Use custom icons
7576

76-
If you want to use icons other than `MaterialCommunityIcons` you need to import the icons and pass it to the `settings` prop within `PaperProvider`.
77+
If you want to use icons other than `MaterialDesignIcons` you need to import the icons and pass it to the `settings` prop within `PaperProvider`.
7778

7879
Example:
7980

8081
```js
81-
import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
82+
import AwesomeIcon from '@react-native-vector-icons/fontawesome';
8283
// ...
8384

84-
<PaperProvider
85-
settings={{
86-
icon: props => <AwesomeIcon {...props} />,
87-
}}
88-
theme={this.state.theme}
89-
>
90-
// ...
91-
</PaperProvider>
85+
<PaperProvider
86+
settings={{
87+
icon: (props) => <AwesomeIcon {...props} />,
88+
}}
89+
theme={this.state.theme}
90+
>
91+
// ...
92+
</PaperProvider>;
9293
```
9394

9495
## RTL support
@@ -102,17 +103,22 @@ If you want your icon to behave properly in a RTL environment, you can pass an o
102103
Example for using an image source:
103104

104105
```js
105-
<Button icon={{ source: { uri: 'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400' }, direction: 'rtl' }}>
106+
<Button
107+
icon={{
108+
source: {
109+
uri: 'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400',
110+
},
111+
direction: 'rtl',
112+
}}
113+
>
106114
Press me
107115
</Button>
108116
```
109117

110118
Example for using an icon name:
111119

112120
```js
113-
<Button icon={{ source: "add-a-photo", direction: 'rtl' }}>
114-
Press me
115-
</Button>
121+
<Button icon={{ source: 'add-a-photo', direction: 'rtl' }}>Press me</Button>
116122
```
117123

118124
You can also use a render function. Along with `size` and `color`, you have access to `direction` which will either be `'rtl'` or `'ltr'`. You can then decide how to render your icon component accordingly.
@@ -131,8 +137,8 @@ Example of using a render function:
131137
{
132138
width: size,
133139
height: size,
134-
tintColor: color
135-
}
140+
tintColor: color,
141+
},
136142
]}
137143
/>
138144
)}

docs/docs/guides/05-react-native-web.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ module.exports = function override(config, env) {
3232
test: /\.js$/,
3333
exclude: /node_modules[/\\](?!react-native-vector-icons)/,
3434
use: {
35-
loader: "babel-loader",
35+
loader: 'babel-loader',
3636
options: {
3737
// Disable reading babel configuration
3838
babelrc: false,
3939
configFile: false,
4040

4141
// The configuration for compilation
4242
presets: [
43-
["@babel/preset-env", { useBuiltIns: "usage" }],
44-
"@babel/preset-react",
45-
"@babel/preset-flow",
46-
"@babel/preset-typescript"
43+
['@babel/preset-env', { useBuiltIns: 'usage' }],
44+
'@babel/preset-react',
45+
'@babel/preset-flow',
46+
'@babel/preset-typescript',
4747
],
4848
plugins: [
49-
"@babel/plugin-proposal-class-properties",
50-
"@babel/plugin-proposal-object-rest-spread"
51-
]
52-
}
53-
}
49+
'@babel/plugin-proposal-class-properties',
50+
'@babel/plugin-proposal-object-rest-spread',
51+
],
52+
},
53+
},
5454
});
5555

5656
return config;
@@ -102,13 +102,9 @@ module.exports = {
102102

103103
// Loaders and resolver config
104104
module: {
105-
rules: [
106-
107-
],
108-
},
109-
resolve: {
110-
105+
rules: [],
111106
},
107+
resolve: {},
112108

113109
// Development server config
114110
devServer: {
@@ -121,17 +117,22 @@ module.exports = {
121117
Also create a folder named `public` and add the following file named `index.html`:
122118

123119
```html
124-
<!doctype html>
120+
<!DOCTYPE html>
125121
<head>
126-
<meta charSet="utf-8" />
122+
<meta charset="utf-8" />
127123
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
128124

129-
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1" />
125+
<meta
126+
name="viewport"
127+
content="width=device-width,minimum-scale=1,initial-scale=1"
128+
/>
130129

131130
<title>App</title>
132131

133132
<style>
134-
html, body, #root {
133+
html,
134+
body,
135+
#root {
135136
height: 100%;
136137
}
137138
@@ -230,7 +231,7 @@ Use `asset/resource`, since `file-loader` was deprecated in webpack v5.
230231
}
231232
```
232233

233-
## Load the Material Community Icons
234+
## Load the Material Design Icons
234235

235236
If you followed the getting started guide, you should have the following code in your root component:
236237

@@ -240,16 +241,16 @@ If you followed the getting started guide, you should have the following code in
240241
</PaperProvider>
241242
```
242243

243-
Now we need tweak this section to load the Material Community Icons from the [`react-native-vector-icons`](https://github.com/oblador/react-native-vector-icons) library:
244+
Now we need tweak this section to load the Material Design Icons from the [`react-native-vector-icons`](https://github.com/oblador/react-native-vector-icons) library:
244245

245246
```js
246247
<PaperProvider>
247248
<React.Fragment>
248249
{Platform.OS === 'web' ? (
249250
<style type="text/css">{`
250251
@font-face {
251-
font-family: 'MaterialCommunityIcons';
252-
src: url(${require('react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf')}) format('truetype');
252+
font-family: 'MaterialDesignIcons';
253+
src: url(${require('@react-native-vector-icons/material-design-icons/fonts/MaterialDesignIcons.ttf')}) format('truetype');
253254
}
254255
`}</style>
255256
) : null}

docs/docs/guides/09-bottom-navigation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ navigation.jumpTo('Profile', { name: 'Michaś' });
195195

196196
```js
197197
import { createMaterialBottomTabNavigator } from 'react-native-paper/react-navigation';
198-
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
198+
import MaterialDesignIcons from '@react-native-vector-icons/material-design-icons';
199199

200200
const Tab = createMaterialBottomTabNavigator();
201201

@@ -212,7 +212,7 @@ function MyTabs() {
212212
options={{
213213
tabBarLabel: 'Home',
214214
tabBarIcon: ({ color }) => (
215-
<MaterialCommunityIcons name="home" color={color} size={26} />
215+
<MaterialDesignIcons name="home" color={color} size={26} />
216216
),
217217
}}
218218
/>
@@ -222,7 +222,7 @@ function MyTabs() {
222222
options={{
223223
tabBarLabel: 'Updates',
224224
tabBarIcon: ({ color }) => (
225-
<MaterialCommunityIcons name="bell" color={color} size={26} />
225+
<MaterialDesignIcons name="bell" color={color} size={26} />
226226
),
227227
}}
228228
/>
@@ -232,11 +232,11 @@ function MyTabs() {
232232
options={{
233233
tabBarLabel: 'Profile',
234234
tabBarIcon: ({ color }) => (
235-
<MaterialCommunityIcons name="account" color={color} size={26} />
235+
<MaterialDesignIcons name="account" color={color} size={26} />
236236
),
237237
}}
238238
/>
239239
</Tab.Navigator>
240240
);
241241
}
242-
```
242+
```

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"@easyops-cn/docusaurus-search-local": "^0.33.4",
2424
"@material/material-color-utilities": "0.2.4",
2525
"@mdx-js/react": "^1.6.22",
26+
"@react-native-vector-icons/common": "^11.0.0",
27+
"@react-native-vector-icons/material-design-icons": "^7.4.47",
2628
"camelcase": "^7.0.1",
2729
"clsx": "^1.2.1",
2830
"color": "^4.2.3",
@@ -32,7 +34,6 @@
3234
"react-color": "^2.19.3",
3335
"react-dom": "17.0.2",
3436
"react-native-safe-area-context": "^4.5.0",
35-
"react-native-vector-icons": "^9.2.0",
3637
"react-native-web": "^0.18.12",
3738
"use-latest-callback": "^0.1.7"
3839
},

docs/plugins/docusaurus-react-native-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = function () {
1111
react: path.resolve('node_modules/react'),
1212
'react-native$': 'react-native-web',
1313
'react-native-paper': path.resolve('../src'),
14-
'react-native-vector-icons': path.resolve(
15-
'node_modules/react-native-vector-icons/dist'
14+
'react-native-vector-icons/MaterialCommunityIcons': path.resolve(
15+
'node_modules/@react-native-vector-icons/material-design-icons'
1616
),
1717
},
1818
extensions: ['.web.js'],

0 commit comments

Comments
 (0)