Skip to content

Commit f473433

Browse files
committed
feat: Setup react native elements
1 parent 248dc24 commit f473433

File tree

5 files changed

+326
-93
lines changed

5 files changed

+326
-93
lines changed

README.md

+2-57
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# React Native Elements on Create React App
22

3-
## Available Scripts
3+
This repo is an example setup for using React Native Elements on the web with create-react-app. This follows the setup guide on https://react-native-training.github.io/react-native-elements/docs/web_usage.html.
44

55
In the project directory, you can run:
66

@@ -11,58 +11,3 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
1111

1212
The page will reload if you make edits.<br>
1313
You will also see any lint errors in the console.
14-
15-
### `npm test`
16-
17-
Launches the test runner in the interactive watch mode.<br>
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `npm run build`
21-
22-
Builds the app for production to the `build` folder.<br>
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br>
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `npm run build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

config-overrides.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const path = require('path');
2+
const { override, addBabelPlugins, babelInclude } = require('customize-cra');
3+
4+
module.exports = override(
5+
...addBabelPlugins('@babel/plugin-proposal-class-properties'),
6+
babelInclude([
7+
path.resolve(__dirname, 'node_modules/react-native-elements'),
8+
path.resolve(__dirname, 'node_modules/react-native-vector-icons'),
9+
path.resolve(__dirname, 'node_modules/react-native-ratings'),
10+
path.resolve(__dirname, 'src'),
11+
])
12+
);

package.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
"dependencies": {
66
"react": "^16.9.0",
77
"react-dom": "^16.9.0",
8+
"react-native-elements": "^1.1.0",
9+
"react-native-vector-icons": "^6.6.0",
10+
"react-native-web": "^0.11.7",
811
"react-scripts": "3.1.1"
912
},
1013
"scripts": {
11-
"start": "react-scripts start",
12-
"build": "react-scripts build",
13-
"test": "react-scripts test",
14+
"start": "react-app-rewired start",
15+
"build": "react-app-rewired build",
16+
"test": "react-app-rewired test",
1417
"eject": "react-scripts eject"
1518
},
1619
"eslintConfig": {
@@ -27,5 +30,10 @@
2730
"last 1 firefox version",
2831
"last 1 safari version"
2932
]
33+
},
34+
"devDependencies": {
35+
"@babel/plugin-proposal-class-properties": "^7.5.5",
36+
"customize-cra": "^0.5.0",
37+
"react-app-rewired": "^2.1.3"
3038
}
3139
}

src/App.js

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import React from 'react';
2-
import logo from './logo.svg';
2+
import { Button } from 'react-native-elements';
3+
34
import './App.css';
45

56
function App() {
67
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
8+
<>
9+
<style type="text/css">{`
10+
@font-face {
11+
font-family: 'MaterialIcons';
12+
src: url(${require('react-native-vector-icons/Fonts/MaterialIcons.ttf')}) format('truetype');
13+
}
14+
15+
@font-face {
16+
font-family: 'FontAwesome';
17+
src: url(${require('react-native-vector-icons/Fonts/FontAwesome.ttf')}) format('truetype');
18+
}
19+
`}</style>
20+
21+
<div className="App">
22+
<header className="App-header">
23+
<Button title="I'm a button from React Native Elements" />
24+
</header>
25+
</div>
26+
</>
2327
);
2428
}
2529

0 commit comments

Comments
 (0)