react: typescript integrate withRouter

define interface:spa

export interface INav {
  nav: string
}

export interface IModuleItem {
  state?: string;
  type?: string;
  uri?: string;
}

use in Function Component:code

import {INav} from "./path/to/menu.ts";

const AppNavigator = (props: INav & RouteComponentProps) => {
  const [currentNav, setCurrentNav] = useState<INav>(props.nav);
  ....
}

export default withRouter(AppNavigator);
相關文章
相關標籤/搜索