Last active
December 2, 2016 09:49
-
-
Save prashaantt/4a9651a0b1d4096d797893178d50e821 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
import * as React from "react"; | |
import { inject, observer } from "mobx-react"; | |
import { withRouter, InjectedRouter } from "react-router"; | |
import { UserStore } from "../../stores/UserStore"; | |
interface MyComponentProps { | |
name: string; | |
countryCode?: string; | |
userStore?: UserStore; | |
router?: InjectedRouter; | |
} | |
@inject("userStore") | |
@withRouter | |
@observer | |
class MyComponent extends React.Component<MyComponentProps, {}> { | |
render() { | |
const { name, countryCode, userStore, router } = this.props; | |
return ( | |
<div> | |
User: { name } <br /> | |
Name: { userStore && userStore.getUserName(name) } <br /> | |
Country: { countryCode && countryCode.toUpperCase() } <br /> | |
<button | |
onClick={() => { router && router.push(`/users/${name}`) }} | |
> | |
Check out user | |
</button> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment