1.1.3 • Published 6 months ago
@itcase/icons v1.1.3
How to Integrate and Use Icons in React Native Project
1. Install Dependencies
- The
react-native-svglibrary is needed to handle SVG files in React Native. If you haven’t installed it yet, follow these steps: https://github.com/software-mansion/react-native-svg
npm install @itcase/icons @itcase/react-native-ui- Сonfigure
metroconfiguration to support packages with differentexports(take configuration from other projects).
2. Using the Icon Component
- MyIcon.tsx
import { icon20 } from '@itcase/icons/default'
import { Icon } from '@itcase/react-native-ui'
import { ISvgComponent } from '../interfaces/app.interfaces'
const MyIcon = () => {
return (
<Icon
SVGIcon={icon20.Dot as unknown as ISvgComponent}
/>
);
}The SVG icon is a string (file path or inline SVG), the react-native-svg library converts it to a component, so we cast it to type ISvgComponent.
3. Project Structure
src/
├── components/
│ └── MyIcon.tsx
├── interfaces/
│ └── app.interfaces.ts
├── types/
│ └── types.d.ts
└── App.tsx4. Defining Custom SVG Component Type
- app.interfaces.ts
import React from 'react'
import { SvgProps } from 'react-native-svg'
export interface ISvgComponent extends React.FC<SvgProps> {}- types.d.ts
declare module '*.svg' {
import React from 'react'
import { SvgProps } from 'react-native-svg'
const content: React.FC<SvgProps>
export default content
}1.1.3
6 months ago
1.1.2
6 months ago
1.1.1
7 months ago
1.1.0
7 months ago
1.0.31
7 months ago
1.0.30
7 months ago
1.0.29
8 months ago
1.0.28
8 months ago
1.0.27
8 months ago
1.0.26
8 months ago
1.0.25
8 months ago
1.0.23
9 months ago
1.0.21
10 months ago
1.0.20
10 months ago
1.0.19
10 months ago
1.0.18
11 months ago
1.0.17
11 months ago
1.0.16
12 months ago
1.0.15
12 months ago
1.0.14
12 months ago
1.0.13
12 months ago
1.0.12
12 months ago
1.0.11
12 months ago
1.0.10
12 months ago
1.0.9
12 months ago
1.0.8
12 months ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago