Created
May 5, 2017 02:25
-
-
Save mikebridge/0c30a19f8c6653c07349e901e97689bc to your computer and use it in GitHub Desktop.
TypeScript control with stacked HOCs
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 {IWithPersonalizationProps, withPersonalization} from "./withPersonalization2"; | |
import {IWithNavigationProps, withNavigation} from "./withNavigation"; | |
// This empty declaration is required | |
interface IWelcomeOwnProps {} | |
type IWelcomeProps = IWelcomeOwnProps & IWithNavigationProps & IWithPersonalizationProps; | |
class Welcome extends React.Component<IWelcomeProps, {}> { | |
constructor(props: IWelcomeProps) { | |
super(props); | |
this.onNameClicked = this.onNameClicked.bind(this); | |
} | |
public render(): JSX.Element { | |
return ( | |
<div onClick={this.onNameClicked}>Welcome, {this.props.name}!</div> | |
); | |
} | |
private onNameClicked<P>(event: React.MouseEvent<P>) { | |
console.log(event); | |
event.preventDefault(); | |
this.props.navigate(); | |
} | |
} | |
export default withNavigation(withPersonalization(Welcome), "/settings"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment