Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
{
"presets": [
"react-native-stage-0/decorator-support"
],
"plugins": [],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
},
"production": {
"plugins": [
"transform-remove-console"
]
}
}
}
"presets": [ "es2015","react-native", "stage-0"]
}
17 changes: 9 additions & 8 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

; Ignore polyfills
.*/Libraries/polyfills/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
node_modules/react-native/flow/

[options]
emoji=true

module.system=haste

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-5]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-5]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true

[version]
^0.45.0
^0.57.0
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ buck-out/
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
# https://docs.fastlane.tools/best-practices/source-control/

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

.vscode
30 changes: 30 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/

import React, { Component } from "react";
import { Router, Scene } from "react-native-router-flux";
import {
Provider,
} from 'react-redux';
import configureStore from './src/store/configureStore';
import Home from "./src/containers/Home";
import Counter from "./src/containers/Counter";
const store = configureStore();

export default class App extends Component {
render() {
return (
<Provider store={store}>
<Router>
<Scene key="root">
<Scene path="home" key="home" component={Home} />
<Scene path="counter" key="counter" component={Counter} />
</Scene>
</Router>
</Provider>
);
}
}
22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# About React Native Boilerplate

## 結構

```
./src
├── actions
│   ├── __tests__
│   │   └── demo.test.js
│   └── demo.js
├── components
│   ├── Counter
│   │   └── index.js
│   ├── Home
│   │   └── index.js
│   └── __tests__
│   ├── Counter.test.js
│   └── Home.test.js
├── constants
│   └── ActionsType.js
├── containers
│   ├── Counter.js
│   └── Home.js
├── reducers
│   ├── __tests__
│   │   ├── __snapshots__
│   │   │   └── demo.test.js.snap
│   │   └── demo.test.js
│   ├── demo.js
│   ├── index.js
│   └── initialState.js
├── sagas
│   └── index.js
└── store
└── configureStore.js
```

### actions

給 View 發送 action 的管道

固定格式為

```javascript
export const less = payload => ({
type: types.LESS,
payload
});
```

* payload : 描述此次 action 所需要的資訊包含 saga 發送 request 需要的資訊

* type: 描述此次 action 的類型,藉由此讓 reducer 可以分辨執行相對應的 update function

### containers

描述每一個頁面和相關連的 `action` 和 `reducer` 的描述

利用 `connect` 來將需要的 `action` 和 `reducer` 利用 props 的形式流入 component 提供使用

### components

每一個資料夾代表一個頁面

描述顯示在瀏覽器上的 HTML CSS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這裡好像打錯了?


藉由 container 來與 `reducer` 和 `action` 產生關聯

來顯示資料與發送 `action`

### reducer

提供 `store` 一個可以修改的接口,依據 `action` 的類型去修改相對應的 data

### sagas

當 `action` 有非同步需求的時候 可以在接收到 `broacast` 之後依據 `action` 的類型去執行後

發送成功或失敗的 `action` 讓 `store` 修改 data

## Test

```
$ npm run test
```

### Test Watch

```
$ npm run test:watch
```

## Trouble shotting

### missing super() call in constructor

```
$ vim ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
```

在 `XMLHttpRequest` 的 `constructor` 中增加 `super()`
8 changes: 8 additions & 0 deletions __tests__/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import "react-native";
import React from "react";
import App from "../App";
import { shallow } from "enzyme";

it("renders correctly", () => {
const tree = shallow(<App />);
});
12 changes: 0 additions & 12 deletions __tests__/index.android.js

This file was deleted.

12 changes: 0 additions & 12 deletions __tests__/index.ios.js

This file was deleted.

5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ import com.android.build.OutputFile
* ]
*/

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
Expand Down Expand Up @@ -133,7 +137,6 @@ android {
}

dependencies {
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
Expand Down
Binary file removed android/app/src/main/assets/fonts/Entypo.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/EvilIcons.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/FontAwesome.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Foundation.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Ionicons.ttf
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/MaterialIcons.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Octicons.ttf
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Zocial.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
Expand All @@ -23,10 +22,14 @@ public boolean getUseDeveloperSupport() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage()
new MainReactPackage()
);
}

@Override
protected String getJSMainModuleName() {
return "index";
}
};

@Override
Expand Down
2 changes: 0 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
rootProject.name = 'RNBoilerplate'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':app'
30 changes: 30 additions & 0 deletions configs/TestSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { JSDOM } = require('jsdom');

const jsdom = new JSDOM();
const { window } = jsdom;

function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === 'undefined')
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
Object.defineProperties(target, props);
}

global.window = window;
global.document = window.document;
global.navigator = {
userAgent: 'node.js',
};
copyProps(window, global);

import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";

Enzyme.configure({ adapter: new Adapter() });

// Ignore React Web errors when using React Native
console.error = (message) => {
return message;
};

require('react-native-mock-render/mock');
1 change: 0 additions & 1 deletion index.android.js

This file was deleted.

1 change: 0 additions & 1 deletion index.ios.js

This file was deleted.

4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('RNBoilerplate', () => App);
Loading