-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
269 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as React from "react"; | ||
import { connect } from "react-redux"; | ||
import * as dataAPI from '../../api/dataAPI'; | ||
import { IRootState } from "../../redux/states"; | ||
import * as test from "../../redux/reducers/test" | ||
import { ADD_COUNT } from "../../redux/actionTypes"; | ||
|
||
const Login = ({count, addCount}) => { | ||
|
||
const testApi = () => { | ||
dataAPI.getBlockNumber().then(res => { | ||
console.log(res) | ||
}) | ||
} | ||
|
||
const add = () => { | ||
addCount(1) | ||
setTimeout(() => { | ||
console.log('>>>',count) | ||
}, 3000); | ||
} | ||
|
||
testApi() | ||
|
||
return ( | ||
<div className="signFlowLoginPage"> | ||
<div>测试redux数据:{count}</div> | ||
<button onClick={add}>+</button> | ||
<button>-</button> | ||
<button>15</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default connect( | ||
(state: IRootState) => { | ||
return { | ||
count: state.test.count | ||
} | ||
}, | ||
dispatch => ({ | ||
addCount: (num) => dispatch({type: ADD_COUNT, num} ) | ||
}) | ||
)(Login); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// test action type | ||
export const ADD_COUNT = "ADD_COUNT" | ||
export const SUB_COUNT = "SUB_COUNT" | ||
export const SET_COUNT = "SET_COUNT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createStore, applyMiddleware } from "redux" | ||
import thunkMiddleware from 'redux-thunk' | ||
import { createLogger } from 'redux-logger' | ||
import reducers from "./reducers" | ||
|
||
const loggerMiddleware: any = createLogger() | ||
|
||
let middlewares = [thunkMiddleware] | ||
|
||
if (process.env.NODE_ENV == 'development') { | ||
middlewares.push(loggerMiddleware) | ||
} | ||
let composeEnhancers = applyMiddleware(...middlewares) | ||
|
||
export default function configureStore(initialState?: any) { | ||
return composeEnhancers(createStore)(reducers, initialState) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { combineReducers } from 'redux' | ||
import test from "./reducers/test"; | ||
|
||
const reducers = combineReducers({ | ||
test | ||
}) | ||
|
||
export default reducers; |
Oops, something went wrong.