File tree Expand file tree Collapse file tree 8 files changed +85
-3
lines changed Expand file tree Collapse file tree 8 files changed +85
-3
lines changed Original file line number Diff line number Diff line change 15
15
"devDependencies" : {
16
16
"babel-core" : " ^6.26.3" ,
17
17
"babel-jest" : " ^23.4.2" ,
18
- "babel-loader" : " ^7.1.5 " ,
18
+ "babel-loader" : " ^8.0.6 " ,
19
19
"babel-polyfill" : " ^6.26.0" ,
20
20
"babel-preset-env" : " ^1.7.0" ,
21
21
"babel-preset-react" : " ^6.24.1" ,
36
36
"webpack-dev-server" : " ^3.1.5"
37
37
},
38
38
"dependencies" : {
39
+ "@babel/core" : " ^7.4.5" ,
40
+ "@babel/preset-env" : " ^7.4.5" ,
41
+ "@babel/preset-react" : " ^7.0.0" ,
39
42
"react" : " ^16.4.2" ,
40
- "react-dom" : " ^16.4.2"
43
+ "react-dom" : " ^16.4.2" ,
44
+ "react-redux" : " ^7.1.0" ,
45
+ "redux" : " ^4.0.1" ,
46
+ "redux-thunk" : " ^2.3.0"
41
47
},
42
48
"babel" : {
43
49
"presets" : [
Original file line number Diff line number Diff line change
1
+ {
2
+ "presets" : [" @babel/preset-env" , " @babel/preset-react" ]
3
+ }
Original file line number Diff line number Diff line change
1
+ import { connect } from 'react-redux' ;
2
+ import { sampleAction } from '../store/actions/sample.actions' ;
3
+
4
+ const SampleComponent = ( ) => { } ;
5
+
6
+ const mapStateToProps = ( state , ownProps ) => {
7
+ return { } ;
8
+ } ;
9
+
10
+ const mapDispatchToProps = dispatch => {
11
+ return {
12
+ testSampleAction : dispatch ( sampleAction ( ) )
13
+ } ;
14
+ } ;
15
+
16
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( SampleComponent ) ;
Original file line number Diff line number Diff line change
1
+ // export all action types relating to this file in any case it's needed in other files
2
+ export const SAMPLE_ACTION = 'SAMPLE_ACTION' ;
3
+ export const SAMPLE_ACTION_WITH_PAYLOAD = 'SAMPLE_ACTION_WITH_PAYLOAD' ;
4
+
5
+ export const sampleAction = ( ) => dispatch => {
6
+ dispatch ( {
7
+ type : SAMPLE_ACTION ,
8
+ } ) ;
9
+ } ;
10
+
11
+ export const sampleActionWithPayload = ( ) => dispatch => {
12
+ const payload = { } ;
13
+
14
+ dispatch ( {
15
+ type : SAMPLE_ACTION_WITH_PAYLOAD ,
16
+ payload,
17
+ } ) ;
18
+ } ;
Original file line number Diff line number Diff line change
1
+ import { createStore , applyMiddleware , compose } from 'redux' ;
2
+ import thunk from 'redux-thunk' ;
3
+ import rootReducer from './reducer' ;
4
+
5
+ const composeEnhancers = window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose ;
6
+ export default ( ) => createStore (
7
+ rootReducer ,
8
+ composeEnhancers ( applyMiddleware ( thunk ) ) ,
9
+ ) ;
Original file line number Diff line number Diff line change
1
+ import { combineReducers } from 'redux' ;
2
+ import sampleReducer from './reducers/sample.reducers' ;
3
+
4
+ export default combineReducers ( {
5
+ sampleReducer,
6
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import * as Actions from '../actions/sample.actions' ;
2
+
3
+ const initialState = {
4
+ hasInitialState : true ,
5
+ } ;
6
+
7
+ const sample = ( state = initialState , action ) => {
8
+ switch ( action . type ) {
9
+ case Actions . SAMPLE_ACTION :
10
+ return { nothing : null } ;
11
+ case Actions . SAMPLE_ACTION_WITH_PAYLOAD :
12
+ return {
13
+ ...state ,
14
+ dataFromWherever : action . payload ,
15
+ } ;
16
+ default :
17
+ return state ;
18
+ }
19
+ } ;
20
+
21
+ export default sample ;
Original file line number Diff line number Diff line change 1
1
import 'babel-polyfill' ;
2
2
import React from 'react' ;
3
3
import ReactDOM from 'react-dom' ;
4
+ import { Provider } from 'react-redux' ;
5
+
6
+ import configureStore from './app/store/configure-store' ;
4
7
import App from './app/App' ;
5
8
import './index.scss' ;
6
9
7
- export const Root = ( ) => < App /> ;
10
+ export const Root = ( ) => < Provider store = { configureStore ( ) } > < App /> </ Provider > ;
8
11
9
12
ReactDOM . render ( < Root /> , document . getElementById ( 'root' ) ) ;
You can’t perform that action at this time.
0 commit comments