Skip to content

Commit efd140f

Browse files
author
schowdhury
committed
(React-Redux): Configuration complete
1 parent 4d28c1c commit efd140f

File tree

8 files changed

+86
-9
lines changed

8 files changed

+86
-9
lines changed

app/config/rootReducer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {combineReducers} from "redux";
2+
import reducerSignup from "../features/signup/reducerSignup";
3+
4+
export default combineReducers({
5+
reducerSignup
6+
})

app/config/store.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {createStore, applyMiddleware, compose} from "redux";
2+
import rootReducer from './rootReducer';
3+
4+
const middlewares = [];
5+
const initialState = {};
6+
7+
const composeEnhancers = (window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
8+
const enhancers = composeEnhancers(applyMiddleware(...middlewares));
9+
10+
export const Store = createStore(rootReducer, initialState, enhancers);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const TypeActionHome = {
2+
checkLogin : "AuthInfo > checkLogin",
3+
signupUser : "Home > signupUser",
4+
};
5+
6+
export const isLoggedIn = () => ({
7+
type: TypeActionHome.checkLogin,
8+
isLoggedIn: true
9+
});

app/features/signup/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, {Component} from 'react';
2+
import {connect} from 'react-redux';
3+
4+
import isLoggedIn from "./actionSignup";
5+
6+
class _Signup extends Component {
7+
render (){
8+
const props = this.props;
9+
return (
10+
<div>
11+
<h4>Status: {props.status.toString()}</h4>
12+
</div>
13+
);
14+
}
15+
}
16+
17+
const mapState = (state) => ({
18+
status: state.reducerSignup.isLoggedIn
19+
})
20+
21+
const mapDispatch = (state) => ({
22+
23+
})
24+
25+
export default connect(mapState, mapDispatch)(_Signup);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {TypeActionHome} from "./actionSignup";
2+
3+
const initialState = {
4+
isLoggedIn: false,
5+
signupData: {}
6+
}
7+
8+
export default (state = initialState, action) => {
9+
switch(action.type) {
10+
case TypeActionHome.checkLogin:
11+
return Object.assign(
12+
{},
13+
state,
14+
{isLoggedIn: action.isLoggedIn}
15+
)
16+
17+
default:
18+
return state;
19+
20+
}
21+
}

app/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
1+
import React from "react";
2+
import ReactDOM from "react-dom";
33

4-
const App = () =>(
5-
<div>
6-
Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!
7-
</div>
8-
)
4+
import {Provider} from "react-redux";
5+
import {Store} from "./config/store";
96

7+
import Signup from "./features/signup";
108

119
ReactDOM.render(
12-
<App/>,
13-
document.getElementById('root')
10+
<Provider store={Store}>
11+
<Signup/>
12+
</Provider>,
13+
document.getElementById("root")
1414
)

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"react-redux": "^5.0.7",
1616
"redux": "^4.0.0",
1717
"redux-observable": "^1.0.0",
18+
"redux-thunk": "^2.3.0",
1819
"rxjs": "^6.3.3"
1920
},
2021
"devDependencies": {

0 commit comments

Comments
 (0)