Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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,
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.