Skip to content

Commit 6bcd7fa

Browse files
author
vinogradov
committed
upgrade dependencies, add examples
1 parent 98dfb1e commit 6bcd7fa

File tree

14 files changed

+1163
-345
lines changed

14 files changed

+1163
-345
lines changed

.eslintrc.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ module.exports = {
6262
'no-useless-call': ['warn'],
6363
'no-useless-concat': ['warn'],
6464
'no-useless-escape': ['warn'],
65-
'no-warning-comments': ['warn'],
6665
'no-with': ['warn'],
6766
'require-await': ['warn'],
6867
'wrap-iife': ['warn'],
@@ -101,7 +100,7 @@ module.exports = {
101100
'computed-property-spacing': ['warn', 'never'],
102101
'consistent-this': ['warn', 'that'],
103102
'func-style': ['warn', 'declaration'],
104-
'indent': ['warn', 4],
103+
'indent': ['warn', 4, {'SwitchCase': 1}],
105104
'key-spacing': ['warn'],
106105
'keyword-spacing': ['warn'],
107106
'linebreak-style': ['warn', 'unix'],
@@ -112,7 +111,6 @@ module.exports = {
112111
'max-statements-per-line': ['warn', {'max': 10}],
113112
'new-cap': ['warn'],
114113
'new-parens': ['warn'],
115-
'newline-after-var': ['warn', 'always'],
116114
'no-lonely-if': ['warn'],
117115
'no-mixed-spaces-and-tabs': ['warn'],
118116
'no-nested-ternary': ['warn'],
@@ -125,7 +123,7 @@ module.exports = {
125123
'object-curly-spacing': ['warn', 'never'],
126124
'one-var-declaration-per-line': ['warn'],
127125
'operator-assignment': ['warn'],
128-
'operator-linebreak': ['warn'],
126+
'operator-linebreak': ['warn', 'after'],
129127
'padded-blocks': ['warn', {'blocks': 'never', 'switches': 'never', 'classes': 'never'}],
130128
'quote-props': ['warn', 'as-needed'],
131129
'quotes': ['warn', 'single'],

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Suitable for:
55
2. Small pet projects/protorypes
66
3. Production
77

8-
**If you don't need some library then just don't use it. Its source code will _NOT_ be included in the final bundle.**
9-
108
# 🎁 What’s Inside?
119

10+
**If you don't need some library then just don't use it. Its source code will _NOT_ be included in the final bundle.**
11+
1212
Name | Type | Original Description | Example Config | Notes
1313
---- | ---- | ------------------ | -------------- | -----
1414
[react](https://facebook.github.io/react/) | View library | A javascript library for building user interfaces
@@ -18,6 +18,7 @@ Name | Type | Original Description | Example Config | Notes
1818
[redux-thunk](https://github.com/gaearon/redux-thunk) | Data management | Thunk middleware for Redux
1919
[redux-saga](https://github.com/redux-saga/redux-saga) | Data management | An alternative side effect model for Redux apps | | An alternative to [redux-thunk](https://github.com/gaearon/redux-thunk). You need to `import "regenerator-runtime/runtime";` for using generators/`yield`
2020
[redux-logger](https://github.com/evgenyrodionov/redux-logger) | Utils | Logger for Redux
21+
[jest](https://github.com/facebook/jest) | QA | Painless JavaScript Testing
2122
[webpack 2](https://webpack.js.org/) | Build tool | A module bundler for modern javascript applications (bundling, minification, watch mode, ect.) | [webpack.config.js](https://github.com/vinogradov/react-starter-kit/blob/master/webpack.config.js) | Loaders: [babel-loader](https://github.com/babel/babel-loader), [eslint-loader](https://github.com/MoOx/eslint-loader), [sass-loader](https://github.com/webpack-contrib/sass-loader)
2223
[babel](https://babeljs.io/) | Transpiler | ES2015/2016/2017 support | [.babelrc](https://github.com/vinogradov/react-starter-kit/blob/master/.babelrc) | Plugins: [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) (spreads are currently [at STAGE 3](https://github.com/sebmarkbage/ecmascript-rest-spread))
2324
[eslint](http://eslint.org/) | Linter | The pluggable linting utility for JavaScript and JSX | [.eslintrc.js](https://github.com/vinogradov/react-starter-kit/blob/master/.eslintrc.js)
@@ -33,8 +34,13 @@ Name | Type | Original Description | Example Config | Notes
3334
`yarn start` (then go http://localhost:8080/)
3435

3536
1. would like to publish the project as a website? Then make a distribution build by generating static files:
36-
`yarn dist`
37+
`yarn dist` (then go to `dist` folder)
3738

3839
If you have problems with running it please [file an issue](https://github.com/vinogradov/react-starter-kit/issues) or [contact me](https://www.facebook.com/vadim.vinogradov) on Facebook
3940

40-
![](http://vinogradov.github.io/react-starter-kit/screenshot.png)
41+
![](http://vinogradov.github.io/react-starter-kit/screenshot.png)
42+
43+
# Examples
44+
45+
1. [examples/react](https://github.com/vinogradov/react-starter-kit/tree/master/src/examples/react) - trivial hello world using React
46+
1. [examples/redux](https://github.com/vinogradov/react-starter-kit/tree/master/src/examples/redux) - counter example with `redux` and `redux-saga`

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
},
1111
"license": "MIT",
1212
"dependencies": {
13-
"babel-core": "6.24.0",
13+
"babel-core": "6.24.1",
14+
"babel-jest": "19.0.0",
1415
"babel-loader": "6.4.1",
1516
"babel-plugin-transform-object-rest-spread": "6.23.0",
16-
"babel-preset-es2015": "6.24.0",
17-
"babel-preset-es2016": "6.22.0",
18-
"babel-preset-es2017": "6.22.0",
19-
"babel-preset-react": "6.23.0",
17+
"babel-preset-es2015": "6.24.1",
18+
"babel-preset-es2016": "6.24.1",
19+
"babel-preset-es2017": "6.24.1",
20+
"babel-preset-react": "6.24.1",
2021
"clean-webpack-plugin": "0.1.16",
2122
"css-loader": "0.28.0",
2223
"eslint": "3.19.0",
@@ -26,14 +27,16 @@
2627
"file-loader": "0.11.1",
2728
"html-webpack-plugin": "2.28.0",
2829
"isomorphic-fetch": "2.2.1",
30+
"jest": "19.0.2",
2931
"node-sass": "4.5.2",
30-
"react": "15.4.2",
31-
"react-dom": "15.4.2",
32-
"react-redux": "5.0.3",
32+
"prop-types": "15.5.6",
33+
"react": "15.5.3",
34+
"react-dom": "15.5.3",
35+
"react-redux": "5.0.4",
3336
"react-router-dom": "4.0.0",
3437
"redux": "3.6.0",
3538
"redux-logger": "3.0.1",
36-
"redux-saga": "0.14.4",
39+
"redux-saga": "0.14.6",
3740
"redux-thunk": "2.2.0",
3841
"sass-loader": "6.0.3",
3942
"style-loader": "0.16.1",

src/entry.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import * as React from 'react';
2-
import * as ReactDOM from 'react-dom';
3-
import HelloMessage from './HelloMessage/HelloMessage';
41
import 'file-loader?name=[name].[ext]!./favicon.ico';
52

6-
ReactDOM.render(
7-
<HelloMessage name="John"/>,
8-
document.querySelector('#app')
9-
);
3+
import './examples/react';
4+
// import './examples/redux';
5+

src/HelloMessage/HelloMessage.js renamed to src/examples/react/hello.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react';
2-
import './HelloMessage.scss';
2+
import PropTypes from 'prop-types';
3+
import './hello.scss';
34

4-
export default class HelloMessage extends React.Component {
5+
export default class Hello extends React.Component {
56
constructor(props) {
67
super(props);
78
this.state = {toggle: true};
@@ -30,6 +31,6 @@ export default class HelloMessage extends React.Component {
3031
}
3132
}
3233

33-
HelloMessage.propTypes = {
34-
name: React.PropTypes.string
35-
};
34+
Hello.propTypes = {
35+
name: PropTypes.string
36+
};
File renamed without changes.

src/examples/react/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as React from 'react';
2+
import * as ReactDOM from 'react-dom';
3+
import Hello from './hello';
4+
5+
ReactDOM.render(
6+
<Hello name="John"/>,
7+
document.querySelector('#app')
8+
);

src/examples/redux/actions.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const INCREMENT_ACTION = 'INCREMENT_ACTION';
2+
export function incrementAction() {
3+
return {
4+
type: INCREMENT_ACTION
5+
};
6+
}
7+
8+
export const DECREMENT_ACTION = 'DECREMENT_ACTION';
9+
export function decrementAction() {
10+
return {
11+
type: DECREMENT_ACTION
12+
};
13+
}
14+
15+
export const DECREMENT_ASYNC_ACTION = 'DECREMENT_ASYNC_ACTION';
16+
export function decrementAsyncAction() {
17+
return {
18+
type: DECREMENT_ASYNC_ACTION
19+
};
20+
}

src/examples/redux/counter.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from 'react';
2+
import {connect} from 'react-redux';
3+
import PropTypes from 'prop-types';
4+
import mapStateToProps from './map-state';
5+
import {incrementAction, decrementAction, decrementAsyncAction} from './actions';
6+
7+
class Counter extends React.Component {
8+
constructor(props) {
9+
super(props);
10+
this.onIncrementHandler = this.onIncrementHandler.bind(this);
11+
this.onDecrementHandler = this.onDecrementHandler.bind(this);
12+
this.onDecrementAsyncHandler = this.onDecrementAsyncHandler.bind(this);
13+
}
14+
15+
onIncrementHandler() {
16+
this.props.dispatch(incrementAction());
17+
}
18+
19+
onDecrementHandler() {
20+
this.props.dispatch(decrementAction());
21+
}
22+
23+
onDecrementAsyncHandler() {
24+
this.props.dispatch(decrementAsyncAction());
25+
}
26+
27+
render() {
28+
return (
29+
<div>
30+
<div>{this.props.counter}</div>
31+
<button onClick={this.onIncrementHandler}>increment</button>
32+
<button onClick={this.onDecrementHandler}>decrement</button>
33+
<button onClick={this.onDecrementAsyncHandler}>decrement async</button>
34+
</div>
35+
);
36+
}
37+
}
38+
39+
Counter.propTypes = {
40+
dispatch: PropTypes.func,
41+
counter: PropTypes.number
42+
};
43+
44+
export default connect(mapStateToProps)(Counter);

src/examples/redux/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
import * as ReactDOM from 'react-dom';
3+
import {createStore, applyMiddleware} from 'redux';
4+
import {Provider} from 'react-redux';
5+
import createSagaMiddleware from 'redux-saga';
6+
import 'regenerator-runtime/runtime';
7+
import {rootReducer} from './reducers';
8+
import Counter from './counter';
9+
import {watchDecrementAsync} from './sagas';
10+
11+
const sagaMiddleware = createSagaMiddleware();
12+
13+
const store = createStore(
14+
rootReducer,
15+
applyMiddleware(sagaMiddleware));
16+
17+
sagaMiddleware.run(watchDecrementAsync);
18+
19+
ReactDOM.render(
20+
<Provider store={store}>
21+
<Counter />
22+
</Provider>,
23+
document.querySelector('#app')
24+
);

0 commit comments

Comments
 (0)