Skip to content

Instantly share code, notes, and snippets.

@velopert
Created August 27, 2018 08:40
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 velopert/bc11b691e128a8932c24f2c645eec8f2 to your computer and use it in GitHub Desktop.
Save velopert/bc11b691e128a8932c24f2c645eec8f2 to your computer and use it in GitHub Desktop.
using mobx inject with typescript
import * as React from 'react';
import { inject, observer } from 'mobx-react';
import Header from 'components/base/Header';
import RootStore from 'stores';
interface HeaderContainerProps {}
interface InjectedProps extends HeaderContainerProps {
mode: string;
visible: boolean;
}
@inject(({ base }: RootStore) => ({
mode: base.header.mode,
visible: base.header.visible,
}))
@observer
class HeaderContainer extends React.Component<HeaderContainerProps> {
get injected() {
return this.props as InjectedProps;
}
public render() {
const { mode, visible } = this.injected;
if (!visible) return null;
return <Header mode={mode} />;
}
}
export default HeaderContainer;
@potados99
Copy link

WOW 감사합니다 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment