Last active
March 10, 2018 14:40
-
-
Save marcoleong/547636508c6778c9cfc7054c403ba86b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function receiveLoginUser (user) { | |
return {type: 'RECEIVE_LOGIN_USER', payload: user} | |
} | |
function login (email, password) { | |
return (dispatch) => { | |
// 可以呢到再dispatch(loadingLogin(true)) | |
return axios.post("xxxx/login", { email, password }).then(response => { | |
dispatch(receiveLoginUser(response.user)) | |
}) | |
} | |
} | |
export { login } |
This file contains hidden or 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
// react | |
import { login } from './login.js' | |
//.....omitted | |
const mapDispatchToProps = (dispatch) => { | |
return { | |
login: (email, password) => { | |
dispatch(login(email, password)) | |
} | |
} | |
} | |
connect(null, mapDispatchToProps)(SomeComponent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment