Skip to content

Commit 8aa8e55

Browse files
committed
feat: tree shaking move to individual components
1 parent 8f1bc45 commit 8aa8e55

1,373 files changed

Lines changed: 891 additions & 7144 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
node_modules/
1+
node_modules/
2+
src/all
3+
src/icons
4+
src/index.tsx
5+
# generated by bob
6+
/lib/

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
example/
33

44
# Scripts
5-
src/generate_icons.sh
5+
src/generate-svg.js
66
test.sh
77

88
# CI

example/.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
4-
};
3+
extends: '@react-native',
4+
};

example/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ yarn-error.log
6161

6262
# Temporary files created by Metro to check the health of the file watcher
6363
.metro-health-check*
64+
65+
# testing
66+
/coverage

example/.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/Gemfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby File.read(File.join(__dir__, '.ruby-version')).strip
5-
6-
gem 'cocoapods', '~> 1.11', '>= 1.11.3'
4+
ruby ">= 2.6.10"
5+
gem 'cocoapods', '~> 1.12'

example/IconsScreen.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import {
1111
useWindowDimensions,
1212
Button
1313
} from 'react-native';
14-
import {Icon} from '@mrkpatchaa/react-native-ionicons';
15-
import {Icons} from '@mrkpatchaa/react-native-ionicons/src/map';
16-
17-
const names = Object.keys(Icons);
14+
import * as IconPack from '@mrkpatchaa/react-native-ionicons';
15+
const { IconContext, ...Icons } = IconPack;
1816

1917
function PickerItem({tag, selection, setSelection}) {
2018
return (
@@ -41,7 +39,7 @@ const App = () => {
4139
const iconSize = (width - 6 * 32) / 5;
4240
const [color, setColor] = useState('');
4341
const [display, setDisplay] = useState('grid');
44-
const [iconStyle, setIconStyle] = useState('outline');
42+
const [mirrorActive, setMirrorActive] = useState(false);
4543

4644
return (
4745
<SafeAreaView style={{flex: 1}}>
@@ -83,7 +81,7 @@ const App = () => {
8381
maxLength={6}
8482
/>
8583
<View style={{flex: 1}} />
86-
<PickerItem
84+
{/* <PickerItem
8785
tag="outline"
8886
selection={iconStyle}
8987
setSelection={setIconStyle}
@@ -97,26 +95,25 @@ const App = () => {
9795
tag="sharp"
9896
selection={iconStyle}
9997
setSelection={setIconStyle}
100-
/>
98+
/> */}
10199
</View>
102100
<FlatList
103101
contentContainerStyle={{paddingHorizontal: 16}}
104102
numColumns={display === 'grid' ? 5 : 1}
105-
data={names.filter(item => iconStyle === 'filled' && !(item.endsWith('-outline') || item.endsWith('-sharp')) || item.endsWith(`-${iconStyle}`))}
106-
keyExtractor={item => item}
103+
data={Object.entries(Icons).filter(([, Icon]) => !!Icon)}
104+
keyExtractor={(item) => item[0]}
107105
key={display}
108-
renderItem={({item}) => {
109-
return (
106+
renderItem={({ item: [name, Icon] }) => (
110107
<View style={{padding: 16, alignItems:'center', flexDirection: display === 'list' ? 'row' : 'column'}}>
111108
<Icon
112-
name={item}
113109
size={iconSize}
114110
color={color.length !== 6 ? '#000' : '#' + color}
111+
mirrored={mirrorActive}
115112
/>
116-
{display === 'list' && <Text style={{marginLeft: 5}}>{item}</Text> }
113+
{display === 'list' && <Text style={{marginLeft: 5}}>{name}</Text> }
117114
</View>
118-
);
119-
}}
115+
)
116+
}
120117
/>
121118
</SafeAreaView>
122119
);

example/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2+
3+
# Getting Started
4+
5+
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6+
7+
## Step 1: Start the Metro Server
8+
9+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10+
11+
To start Metro, run the following command from the _root_ of your React Native project:
12+
13+
```bash
14+
# using npm
15+
npm start
16+
17+
# OR using Yarn
18+
yarn start
19+
```
20+
21+
## Step 2: Start your Application
22+
23+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24+
25+
### For Android
26+
27+
```bash
28+
# using npm
29+
npm run android
30+
31+
# OR using Yarn
32+
yarn android
33+
```
34+
35+
### For iOS
36+
37+
```bash
38+
# using npm
39+
npm run ios
40+
41+
# OR using Yarn
42+
yarn ios
43+
```
44+
45+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46+
47+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48+
49+
## Step 3: Modifying your App
50+
51+
Now that you have successfully run the app, let's modify it.
52+
53+
1. Open `App.tsx` in your text editor of choice and edit some lines.
54+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
55+
56+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
57+
58+
## Congratulations! :tada:
59+
60+
You've successfully run and modified your React Native App. :partying_face:
61+
62+
### Now what?
63+
64+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66+
67+
# Troubleshooting
68+
69+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70+
71+
# Learn More
72+
73+
To learn more about React Native, take a look at the following resources:
74+
75+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
76+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import 'react-native';
66
import React from 'react';
77
import App from '../App';
88

9+
// Note: import explicitly to use the types shiped with jest.
10+
import {it} from '@jest/globals';
11+
12+
913
// Note: test renderer must be required after react-native.
1014
import renderer from 'react-test-renderer';
1115

0 commit comments

Comments
 (0)