Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Commit 3547849

Browse files
author
Reinaldo Haynes
committed
README overhaul.
1 parent cda4e61 commit 3547849

File tree

3 files changed

+81
-35
lines changed

3 files changed

+81
-35
lines changed

README.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,70 @@
11
React + Redux Web Native App
22
--------------------
33

4-
The goal of this build is to create a react web and native app using a shared codebase while keeping the integrity of the `create-react-app` and `react-native` build structure...because, who want's to waste time creating the build process.
4+
The goal of this build is to create a react web and native app using a shared codebase while keeping the integrity of the `create-react-app` and `react-native` build structure...because, who want's to waste time creating the build process or updating custom functionality each version. 🤔
55

66
![App Preview](https://i.imgur.com/vyLoIxd.png)
77

88
### Quick Start
99

10-
1. Clone this repo.
10+
1. Clone this repo:
11+
`git clone git@github.com:ReyHaynes/react-redux-web-native.git <AppNameHere>`
1112

12-
2. (Optional) Rename your app in the `app.json` file.
13+
2. `cd` into project and remove the `.git` folder and create your own repo.
14+
```
15+
cd <AppNameHee>
16+
rm -rf .git
17+
```
18+
19+
3. Rename your app in the `app.json` file.
1320

14-
3. Install dependencies with `yarn install` or `npm install`.
21+
4. Install dependencies with `yarn install` or `npm install`.
1522

16-
4. Build the `/ios` and `/android` native files with `yarn eject:app`
23+
5. Build the `/ios` and `/android` native files with `yarn app:eject`
1724

18-
5. Code the greatest app of all time. 🤔
25+
6. Run developing environments.
26+
```
27+
yarn web:start
28+
yarn ios:start
29+
yarn android:start
30+
```
31+
32+
7. Code the greatest app of all time. 🤔
1933

2034
### Requirements
2135

2236
This is a `node` based build app so having node installed is an obvious requirement!
2337

38+
`node` version 8+ highly recommended.
39+
2440
`react-native` requires you to have the proper emulators installed for your targeted operating system. Check out the [React Native docs at Facebook](https://facebook.github.io/react-native/docs/getting-started.html) to get the install instructions. Make sure to use the instructions under the "Building Projects with Native Code" tab.
2541

2642
(Optional) `npm` is installed with node but I recommend `yarn` package management. Instruction to install Yarn [can be found here](https://yarnpkg.com/en/docs/install).
2743

44+
### Workflow
45+
```
46+
Index (entry files)
47+
-> App <- (Storage & Routing)
48+
-> Screens -> Components
49+
-> Actions -> Reducers
50+
```
51+
`index.js (entry files)`: The index entry files shouldn't need editing.
52+
53+
`App.js`: The highest level component. Should be clean and contain the main routes for the app.
54+
55+
`storage/ & routing/`: Manages the storage and routing for web and native. Shouldn't need editing unless necessary.
56+
57+
`screens/<ScreenName>.js`: The highest level component for each screen in your app. Should contain all of the pure logic to be passed down to components. Screens should also contain connection to the redux store through `connect()`.
58+
59+
`components/<ComponentName>/`: Pure, stacked or presentational components that will be used in *Screens*. Presentational components should include `.js`, `.ios.js` & `.android.js` files to work across native and web builds.
60+
2861
### Issues / Gotchas
2962

3063
###### Testing
3164
Unfortunately, since the testing environments are different for native and web, and there's no real way for jest to interpret the difference from web and native renders. Any testing you would like to do must be done within `__tests__/<native/web>` directories.
3265

3366
###### File Naming
34-
You will want to separate presentational containers (anything with `render()` for the most part). Since there is no graceful way to determine native and web platform and there is no `.web.js` file extension, presentational containers for the Web should be under the main `.js` file while Native should be under `.ios.js` and `.android.js`.
67+
You will want to separate presentational containers (anything with `render()` for the most part). Since there is no graceful way to determine native and web platform and there is no `.web.js` file extension without hacking into react itself, presentational containers for the Web should be under the main `.js` file while Native should be under `.ios.js` and `.android.js`.
3568

3669
Please note, that if you are targeting both platforms, you will be **required** to use both file name extensions since it will default to the main file if the extension does not exist.
3770

@@ -49,31 +82,41 @@ export { App as default }
4982
###### How do I rename the app?
5083
If you already have the `/ios` & `/android` directories installed, in order to rename the app, delete these directories and run `react-native eject`.
5184

52-
To do this in one command, use `yarn eject:app` or `npm run eject:app`.
85+
To do this in one command, use `yarn app:eject` or `npm run app:eject`.
86+
87+
###### How to link native code?
88+
Linking code is similar to doing it with the `react-native`. You can run `yarn app:link`, `npm run app:link` or `react-native link`.
89+
90+
If you *eject* your app, please remember to re-link your native code again.
91+
92+
###### Shouldn't I commit the `/ios` & `/android` directories?
93+
You absolutely should. It's a good idea to remove the `.gitignore` for
94+
5395

5496
### Additional Options
5597

5698
Commands can be executed with `yarn <options>` or `npm run <options>`
5799

58100
| Options | Description |
59101
| --------- | ----------- |
60-
| install | Install dependencies and (re)build `/ios` & `/android` directories. |
102+
| install | Install project dependencies. |
61103
| test | Run tests in `/__tests__` directory. |
62104
| | |
63-
| web | Start React Web |
64-
| build:web | Generate build for React Web |
65-
| test:web | Run test watcher for React Web from `/__tests__/web` directory. |
66-
| eject:web | Eject `create-react-app` for custom React Web |
105+
| web:start | Start React Web |
106+
| web:build | Generate build for React Web |
107+
| web:test | Run test watcher for React Web from `/__tests__/web` directory. |
108+
| web:eject | Eject `create-react-app` for custom React Web |
67109
| | |
68-
| start:app | Start background process for React Native |
69-
| test:app | Run test watcher for React Native from `/__tests__/native` directory. |
70-
| eject:app | (Re)Build `/ios` & `/android` directories. |
110+
| app:start | Start background process for React Native |
111+
| app:test | Run test watcher for React Native from `/__tests__/native` directory. |
112+
| app:eject | (Re)Build `/ios` & `/android` directories. |
113+
| app:link | Link native libraries. |
71114
| | |
72-
| ios | Run iOS emulator. Similar to `react-native run-ios` |
115+
| ios:start | Run iOS emulator. Similar to `react-native run-ios` |
73116
| ios:bundle | Bundle with entry file index.js |
74117
| ios:build | Run iOS emulator with a "Release" configuration. |
75118
| | |
76-
| android | Run Android emulator. Similar to `react-native run-android` |
119+
| android:start | Run Android emulator. Similar to `react-native run-android` |
77120
| android:clean | Fix building android if preDexDebug error |
78121
| android:bundle | Bundle with entry file index.js |
79122
| android:build | Build with a "Release" configuration. |
@@ -84,10 +127,12 @@ Commands can be executed with `yarn <options>` or `npm run <options>`
84127
- [x] Merge `create-react-app` & `react-native`
85128
- [x] Create Sample App (Web & Native)
86129
- [x] Implement Redux sample Action and Reducer
87-
- [x] Unit testing
88130
- [x] Data Storage via `redux-persist`
89-
- [ ] Create sample action buttons
90131
- [ ] Add Electron (Desktop App Build)
132+
- [ ] Create sample testing suite
133+
- [ ] Create web/native compatible components
134+
- [ ] Themify web/native components
135+
- [ ] Better clone process
91136

92137
### Contribute
93138

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
"url": "https://github.com/ReyHaynes/react-redux-web-native/issues"
1313
},
1414
"scripts": {
15-
"start": "echo '\"start\" script has been replaced with \"start:web\" & \"start:app\"'",
16-
"build": "echo '\"build\" script has been replaced with \"build:web\"'",
17-
"eject": "echo '\"eject\" script has been replaced with \"eject:web\" & \"eject:app\"'",
18-
"test": "yarn test:web && yarn test:app",
19-
"web": "react-scripts start",
20-
"build:web": "react-scripts build",
21-
"test:web": "jest --env=jsdom --testMatch='<rootDir>/__tests__/web/**/*.js?(x)'",
22-
"eject:web": "react-scripts eject",
23-
"start:app": "node node_modules/react-native/local-cli/cli.js start",
24-
"test:app": "jest --preset=react-native --testMatch='<rootDir>/__tests__/native/**/*.js?(x)'",
25-
"eject:app": "rm -rf ./android && rm -rf ./ios && react-native eject",
26-
"link:app": "react-native link",
27-
"ios": "react-native run-ios",
15+
"start": "echo '\"start\" script has been replaced with \"web:start\" & \"app:start\"'",
16+
"build": "echo '\"build\" script has been replaced with \"web:build\"'",
17+
"eject": "echo '\"eject\" script has been replaced with \"web:eject\" & \"app:eject\"'",
18+
"test": "yarn web:test && yarn app:test",
19+
"web:start": "react-scripts start",
20+
"web:build": "react-scripts build",
21+
"web:test": "jest --env=jsdom --testMatch='<rootDir>/__tests__/web/**/*.js?(x)'",
22+
"web:eject": "react-scripts eject",
23+
"app:start": "node node_modules/react-native/local-cli/cli.js start",
24+
"app:test": "jest --preset=react-native --testMatch='<rootDir>/__tests__/native/**/*.js?(x)'",
25+
"app:eject": "rm -rf ./android && rm -rf ./ios && react-native eject",
26+
"app:link": "react-native link",
27+
"ios:start": "react-native run-ios",
2828
"ios:bundle": "react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios",
2929
"ios:build": "react-native run-ios --configuration Release",
30-
"android": "react-native run-android",
30+
"android:start": "react-native run-android",
3131
"android:clean": "cd android && ./gradlew clean",
3232
"android:build": "cd android && ./gradlew assembleRelease",
3333
"android:bundle": "react-native bundle --platform android --dev false --entry-file ./index.android.js --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./android/app/src/main/assets/index.android.map --assets-dest ./android/app/src/main/res/",

src/index.ios.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
import { AppRegistry } from 'react-native'
44
import App from './App'
5+
import appConfig from '../app.json'
56

6-
AppRegistry.registerComponent('SampleWebNative', () => App)
7+
AppRegistry.registerComponent(appConfig.name, () => App)

0 commit comments

Comments
 (0)