Created
May 22, 2019 06:11
-
-
Save js2me/5eedaa469a42bcf0a86805763146efd5 to your computer and use it in GitHub Desktop.
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
// login component | |
import { connect } from 'react-stonex | |
const Login = ({ firstName, lastName, changeAuthData }) => ( | |
<div> | |
<input value={firstName} onChange={e => this.changeAuthData('firstName', e.target.value)} /> | |
<input value={lastName} onChange={e => this.changeAuthData('lastName', e.target.value)} /> | |
</div> | |
) | |
export default connect((state, modules) => ({ | |
firstName: state.auth.firstName, | |
lastName: state.auth.lastName, | |
changeAuthData: modules.auth.changeAuthData, | |
}))(Login) | |
// somewhere in sidebar component | |
import { connect } from 'react-stonex | |
const Sidebar = ({ firstName, lastName }) => ( | |
<div> | |
<span>Hello, {firstName} {lastName}</span> | |
</div> | |
) | |
export default connect((state, modules) => ({ | |
firstName: state.auth.firstName, | |
lastName: state.auth.lastName, | |
}))(Sidebar) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment