Skip to content

Commit 4c3531c

Browse files
authored
Merge pull request #6 from vladimir-paziuk/feature/react-router
TypeScript / Redux / Redux sagas / React router v4
2 parents 3546a2a + 8037bf1 commit 4c3531c

File tree

26 files changed

+546
-74
lines changed

26 files changed

+546
-74
lines changed

.gitignore

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
1+
################################################
2+
# Dependencies
3+
#
4+
# When releasing a production app, you may
5+
# consider including your node_modules and
6+
# bower_components directory in your git repo,
7+
# but during development, its best to exclude it,
8+
# since different developers may be working on
9+
# different kernels, where dependencies would
10+
# need to be recompiled anyway.
11+
#
12+
# More on that here about node_modules dir:
13+
# http://www.futurealoof.com/posts/nodemodules-in-git.html
14+
# (credit Mikeal Rogers, @mikeal)
15+
#
16+
# About bower_components dir, you can see this:
17+
# http://addyosmani.com/blog/checking-in-front-end-dependencies/
18+
# (credit Addy Osmani, @addyosmani)
19+
#
20+
################################################
21+
122
node_modules
23+
bower_components
224
dist
3-
package-lock.json
25+
26+
27+
28+
################################################
29+
# Sails.js / Waterline / Grunt
30+
#
31+
# Files generated by Sails and Grunt, or related
32+
# tasks and adapters.
33+
################################################
34+
.tmp
35+
dump.rdb
36+
37+
38+
39+
40+
41+
################################################
42+
# Node.js / NPM
43+
#
44+
# Common files generated by Node, NPM, and the
45+
# related ecosystem.
46+
################################################
47+
lib-cov
48+
*.seed
49+
*.log
50+
*.out
51+
*.pid
52+
npm-debug.log
53+
54+
55+
56+
57+
58+
################################################
59+
# Miscellaneous
60+
#
61+
# Common files generated by text editors,
62+
# operating systems, file systems, etc.
63+
################################################
64+
65+
*~
66+
*#
67+
.DS_STORE
68+
.netbeans
69+
nbproject
70+
.idea
71+
.node_history
72+
package-lock.json

README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# React Webpack Starter
2-
> This is a boilerplate for React 16 & Webpack 4. It includes webpack-dev-server and a build script
3-
41
## Quick Start
52

63
``` bash
@@ -13,18 +10,3 @@ npm start
1310
# Build for production
1411
npm run build
1512
```
16-
17-
## App Info
18-
19-
### Author
20-
21-
Brad Traversy
22-
[Traversy Media](http://www.traversymedia.com)
23-
24-
### Version
25-
26-
1.0.0
27-
28-
### License
29-
30-
This project is licensed under the MIT License

package.json

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,53 @@
55
"main": "index.js",
66
"scripts": {
77
"start": "webpack-dev-server --mode development --open --hot",
8-
"build": "webpack --mode production"
8+
"build": "./node_modules/.bin/webpack --mode production"
99
},
10-
"author": "Brad Traversy",
10+
"author": "Brad Traversy & Vladimir Paziuk",
1111
"license": "MIT",
1212
"dependencies": {
13-
"react": "^16.2.0",
14-
"react-dom": "^16.2.0"
13+
"history": "^4.7.2",
14+
"react": "^16.4.1",
15+
"react-dom": "^16.4.1",
16+
"react-redux": "^5.0.7",
17+
"react-router-dom": "^4.3.1",
18+
"react-router-redux": "^5.0.0-alpha.9",
19+
"redux": "^4.0.0",
20+
"redux-saga": "^0.16.0"
1521
},
1622
"devDependencies": {
23+
"@types/history": "^4.7.0",
24+
"@types/react": "^16.4.7",
25+
"@types/react-dom": "^16.0.6",
26+
"@types/react-redux": "^6.0.6",
27+
"@types/react-router-dom": "^4.3.0",
28+
"@types/react-router-redux": "^5.0.15",
29+
"autoprefixer": "^9.0.2",
1730
"babel-core": "^6.26.0",
1831
"babel-loader": "^7.1.4",
1932
"babel-preset-env": "^1.6.1",
2033
"babel-preset-react": "^6.24.1",
34+
"clean-webpack-plugin": "^0.1.19",
2135
"css-loader": "^0.28.11",
36+
"file-loader": "^1.1.11",
2237
"html-webpack-plugin": "^3.1.0",
38+
"node-sass": "^4.9.2",
39+
"postcss-loader": "^2.1.6",
40+
"redux-devtools-extension": "^2.13.5",
41+
"sass-loader": "^7.0.3",
2342
"style-loader": "^0.20.3",
43+
"ts-loader": "^4.4.2",
44+
"tslint": "^5.11.0",
45+
"tslint-loader": "^3.6.0",
46+
"tslint-react": "^3.6.0",
47+
"typescript": "^2.9.2",
2448
"webpack": "^4.4.0",
2549
"webpack-cli": "^2.0.13",
2650
"webpack-dev-server": "^3.1.1"
51+
},
52+
"browserslist": {
53+
"production": [
54+
"last 3 version"
55+
]
2756
}
2857
}

src/App.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from "react";
2+
import { compose } from "redux";
3+
import { withRouter } from "react-router-dom";
4+
5+
import routes from "./routes";
6+
7+
class App extends React.Component<any, {}> {
8+
render(): JSX.Element {
9+
console.log(this.props);
10+
11+
return (
12+
<div>
13+
{routes}
14+
</div>
15+
);
16+
}
17+
}
18+
19+
export default compose(
20+
withRouter,
21+
)(App);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const FETCH_DATA: string = "main => FETCH_DATA";

src/actions/MainActions/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { FETCH_DATA } from "./MainTypes";
2+
import { START, SUCCESS, ERROR } from "../commonActionTypes";
3+
import { IActionCreator } from "../../interfaces/IReducers";
4+
5+
export const startFetchingData: IActionCreator = () => ({
6+
type: FETCH_DATA + START,
7+
});
8+
9+
export const fetchDataSuccess: IActionCreator<string[]> = (payload) => ({
10+
type: FETCH_DATA + SUCCESS,
11+
payload,
12+
});
13+
14+
export const fetchDataError: IActionCreator<string> = (payload) => ({
15+
type: FETCH_DATA + ERROR,
16+
payload,
17+
});
18+
19+
export const fetchData: IActionCreator = () => ({
20+
type: FETCH_DATA,
21+
});

src/actions/commonActionTypes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const START: string = "_START";
2+
export const STOP: string = "_STOP";
3+
export const RESET: string = "_RESET";
4+
export const SUCCESS: string = "_SUCCESS";
5+
export const ERROR: string = "_ERROR";

src/actions/createRequestTypes.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const REQUEST: string = "REQUEST";
2+
const SUCCESS: string = "SUCCESS";
3+
const FAILURE: string = "FAILURE";
4+
5+
export interface IRequestTypes {
6+
[key: string]: string;
7+
}
8+
9+
function createRequestTypes(base: string): IRequestTypes {
10+
return [REQUEST, SUCCESS, FAILURE].reduce((acc: IRequestTypes, type) => {
11+
acc[type] = `${base}_${type}`;
12+
return acc;
13+
}, {});
14+
}
15+
16+
export default createRequestTypes;

src/components/App.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<html lang="en">
33

44
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<title>My React App</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>My React App</title>
99
</head>
1010

1111
<body>
12-
<div id="app"></div>
12+
<div id="app"></div>
1313
</body>
1414

15-
</html>
15+
</html>

0 commit comments

Comments
 (0)