Skip to content

Commit 285c49f

Browse files
committed
version 1 of create-react-redux-thunk-app
0 parents  commit 285c49f

File tree

27 files changed

+583
-0
lines changed

27 files changed

+583
-0
lines changed

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
yarn.lock
16+
.idea
17+
.DS_Store
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## React Redux with Redux Thunk Starter Kit
2+
* React + Redux directory structure has been created with redux configuration
3+
* Sample container and presentational component created, using counter value from redux store
4+
* Sample routes added
5+
* Uses Jest for running unit test
6+
* Can add your own test using extension *.test.js
7+
* Can check the npm bundler/build scripts inside node_modules/react-scripts
8+
9+
#####This project aims at helping kickstarting a new react redux project which uses redux thunk as middleware.
10+
11+
* Step 1: `clone this repository`
12+
* Step 2: navigate inside the project folder `cd create-react-redux-thunk-app`
13+
* Step 3: do `npm install` or `yarn install`
14+
15+
######Use following scripts to run this project on development mode, create production build and run unit tests
16+
17+
## Available Scripts
18+
######uses [React-scripts](https://www.npmjs.com/package/react-scripts) for build creation and running tests
19+
20+
In the project directory, you can run:
21+
22+
### `npm start`
23+
24+
Runs the app in the development mode.<br>
25+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
26+
27+
The page will reload if you make edits.<br>
28+
You will also see any lint errors in the console.
29+
30+
### `npm test`
31+
32+
Launches the test runner in the interactive watch mode.<br>
33+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
34+
35+
### `npm run build`
36+
37+
Builds the app for production to the `build` folder.<br>
38+
It correctly bundles React in production mode and optimizes the build for the best performance.
39+
40+
The build is minified and the filenames include the hashes.<br>
41+
Your app is ready to be deployed!
42+
43+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
44+
45+
### `npm run eject`
46+
47+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
48+
49+
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.
50+
51+
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.
52+
53+
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.
54+
55+
## Learn More
56+
57+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
58+
59+
To learn React, check out the [React documentation](https://reactjs.org/).
60+
61+
### Code Splitting
62+
63+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
64+
65+
### Analyzing the Bundle Size
66+
67+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
68+
69+
### Making a Progressive Web App
70+
71+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
72+
73+
### Advanced Configuration
74+
75+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
76+
77+
### Deployment
78+
79+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
80+
81+
### `npm run build` fails to minify
82+
83+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
84+
85+
#### For Pull Requests
86+
Aim is to keep this repository as simple and light as we can, only add packages which actually increases the productivity or app performance i.e raise PR for a must to have package/feature, looking forward to contributions.
87+
88+
#####Starter kit created by[Bhupinder Singh](https://github.com/dynamicsingh), folllow me on twitter[@dynamicsingh](https://twitter.com/dynamicsingh)

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "create-react-redux-thunk-app",
3+
"version": "1.0.0",
4+
"author": "Bhupinder Singh: @dynamicsingh",
5+
"repository": "dynamicsingh/create-react-redux-thunk-app",
6+
"dependencies": {
7+
"node-sass": "^4.11.0",
8+
"react": "^16.7.0",
9+
"react-dom": "^16.7.0",
10+
"react-redux": "^6.0.0",
11+
"react-router-dom": "^4.3.1",
12+
"react-scripts": "2.1.2",
13+
"redux": "^4.0.1",
14+
"redux-thunk": "^2.3.0"
15+
},
16+
"scripts": {
17+
"start": "react-scripts start",
18+
"build": "react-scripts build",
19+
"test": "react-scripts test",
20+
"eject": "react-scripts eject"
21+
},
22+
"eslintConfig": {
23+
"extends": "react-app"
24+
},
25+
"browserslist": [
26+
">0.2%",
27+
"not dead",
28+
"not ie <= 11",
29+
"not op_mini all"
30+
],
31+
"license": "MIT",
32+
"keywords": [
33+
"npm",
34+
"package",
35+
"react",
36+
"redux",
37+
"redux-thunk",
38+
"starter kit",
39+
"boilerplate"
40+
]
41+
}

public/favicon.ico

3.78 KB
Binary file not shown.

public/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9+
/>
10+
<meta name="theme-color" content="#000000" />
11+
<!--
12+
manifest.json provides metadata used when your web app is added to the
13+
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
14+
-->
15+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16+
<!--
17+
Notice the use of %PUBLIC_URL% in the tags above.
18+
It will be replaced with the URL of the `public` folder during the build.
19+
Only files inside the `public` folder can be referenced from the HTML.
20+
21+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
22+
work correctly both with client-side routing and a non-root public URL.
23+
Learn how to configure a non-root public URL by running `npm run build`.
24+
-->
25+
<title>React Redux App</title>
26+
</head>
27+
<body>
28+
<noscript>You need to enable JavaScript to run this app.</noscript>
29+
<div id="root"></div>
30+
<!--
31+
This HTML file is a template.
32+
If you open it directly in the browser, you will see an empty page.
33+
34+
You can add webfonts, meta tags, or analytics to this file.
35+
The build step will place the bundled scripts into the <body> tag.
36+
37+
To begin the development, run `npm start` or `yarn start`.
38+
To create a production bundle, use `npm run build` or `yarn build`.
39+
-->
40+
</body>
41+
</html>

public/manifest.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as types from '../actionTypes';
2+
3+
export function sampleActionCreator(updateVal) {
4+
return function (dispatch) {
5+
// thunks allow for pre-processing actions, calling apis, and dispatching multiple actions
6+
return dispatch({
7+
type: types.SAMPLE_ACTION_TYPE,
8+
val: updateVal
9+
});
10+
};
11+
}

src/actionTypes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SAMPLE_ACTION_TYPE = 'SAMPLE_ACTION_TYPE';

src/assets/images/logo.svg

Lines changed: 7 additions & 0 deletions
Loading

src/components/App.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, {Component} from 'react';
2+
import AppTextComponent from './presentational/appText/appText';
3+
import {BrowserRouter as Router} from 'react-router-dom';
4+
import Route from 'react-router-dom/Route';
5+
import SampleContainer from '../components/containers/sampleContainer/sampleContainer';
6+
7+
class App extends Component {
8+
render() {
9+
return (
10+
<Router>
11+
<div className="App">
12+
<Route exact path="/" component={AppTextComponent}/>
13+
<Route exact path="/sampleRoute" component={SampleContainer}/>
14+
</div>
15+
</Router>
16+
);
17+
}
18+
}
19+
20+
export default App;

src/components/App.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
7+
ReactDOM.render(<App />, div);
8+
ReactDOM.unmountComponentAtNode(div);
9+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, {Component} from 'react';
2+
import {connect} from 'react-redux';
3+
import SampleComponent from './../../presentational/sampleComponent/sampleComponent';
4+
import {sampleActionCreator} from './../../../actionCreators/sampleActionCreator';
5+
6+
class SampleContainer extends Component {
7+
render(){
8+
return(
9+
<div className="sampleContainer">
10+
<SampleComponent
11+
counterVal={this.props.counterVal}
12+
updateCounter={() => this.props.updateCounter(1)}
13+
componentLabel={'Sample component is loading inside sample container with counter val:'}/>
14+
</div>
15+
);
16+
}
17+
}
18+
19+
const mapStateToProps = (state) => {
20+
return {
21+
counterVal: state.sample.counter || 0
22+
}
23+
};
24+
25+
const mapDispatchToProps = (dispatch) => {
26+
return {
27+
updateCounter : (counter) => dispatch(sampleActionCreator(counter))
28+
}
29+
};
30+
31+
export default connect(mapStateToProps, mapDispatchToProps)(SampleContainer);
32+
/* connect(mapStateToProps, mapDispatchToProps) is HOC which will return a component
33+
*/

src/components/containers/sampleContainer/sampleContainer.test.js

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import logo from '../../../assets/images/logo.svg';
3+
4+
const appTextComponent = () => {
5+
return (
6+
<header className="App-header">
7+
<img src={logo} className="App-logo" alt="logo"/>
8+
<p>This is React Redux starter kit with Redux Thunk</p>
9+
<br/>
10+
<p>
11+
<a className="App-link" href={'/sampleRoute'}>Sample Component</a>
12+
</p>
13+
<a
14+
className="App-link"
15+
href="https://github.com/dynamicsingh"
16+
target="_blank"
17+
rel="noopener noreferrer"
18+
>
19+
Starter kit created by : Bhupinder Singh
20+
</a>
21+
</header>
22+
);
23+
};
24+
export default appTextComponent;

src/components/presentational/appText/appText.test.js

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
const SampleComponent = ({componentLabel = 'default prop label', counterVal, updateCounter}) => {
4+
return (
5+
<div style={{paddingTop: 30}}>
6+
<div>{componentLabel} {counterVal}</div>
7+
<button style={{marginTop: 30}} onClick={updateCounter}>Update Counter</button>
8+
</div>
9+
);
10+
};
11+
12+
export default SampleComponent;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
const SampleComponent = ({componentLabel = 'default prop label', counterVal, updateCounter}) => {
4+
return (
5+
<div style={{paddingTop: 30}}>
6+
<div>{componentLabel} {counterVal}</div>
7+
<button style={{marginTop: 30}} onClick={updateCounter}>Update Counter</button>
8+
</div>
9+
);
10+
};
11+
12+
export default SampleComponent;

src/constants/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
API: 'http://sampleApiurl.com'
3+
}

src/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import './styles/index.scss';
4+
import App from './components/App';
5+
import * as serviceWorker from './utils/serviceWorker';
6+
7+
//Linking Redux to App
8+
import {Provider} from 'react-redux';
9+
import storeConfiguration from './store/configureStore';
10+
11+
ReactDOM.render(
12+
<Provider store={storeConfiguration}>
13+
<App />
14+
</Provider>
15+
, document.getElementById('root'));
16+
17+
// If you want your app to work offline and load faster, you can change
18+
// unregister() to register() below. Note this comes with some pitfalls.
19+
// Learn more about service workers: http://bit.ly/CRA-PWA
20+
serviceWorker.unregister();

src/reducers/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { combineReducers } from 'redux';
2+
import sample from './sampleReducer';
3+
4+
const rootReducer = combineReducers({
5+
sample
6+
});
7+
8+
export default rootReducer;

0 commit comments

Comments
 (0)