Skip to content

Instantly share code, notes, and snippets.

@js2me
Created May 22, 2019 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save js2me/5eedaa469a42bcf0a86805763146efd5 to your computer and use it in GitHub Desktop.
Save js2me/5eedaa469a42bcf0a86805763146efd5 to your computer and use it in GitHub Desktop.
// 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