Skip to content

Instantly share code, notes, and snippets.

@radzserg
Last active July 12, 2019 08:38
Show Gist options
  • Select an option

  • Save radzserg/570deeb5209f48f20de0967a8643f36c to your computer and use it in GitHub Desktop.

Select an option

Save radzserg/570deeb5209f48f20de0967a8643f36c to your computer and use it in GitHub Desktop.
/HomePage/HomePage.tsx
import { History } from "history";
interface IProps {
label: string;
history: History;
}
class HomePage extends PureComponent<IProps> {
render() {
return (
<div>
Home page {this.props.label}
<a onClick={this.props.history.push("/catalog")}>Catalog</a>
</div>
);
}
}
// HomePage/connected.tsx
interface IInjectedProps {
history: History;
}
withInjection<IProps, IInjectedProps>(HomePage, {
// prop name in component: dependency name in DI container.
history: APP_DEP.BROWSER_HISTORY
});
// HomePage/index.tsx
import HomePage from "./connected.tsx"
export default HomePage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment