index.tsx 813 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { ReactType } from "react";
  2. import { Route, RouteComponentProps } from 'react-router-dom';
  3. import RecipeList from './List';
  4. import Create from './Create';
  5. const view = (props: any) => (
  6. <div>
  7. <h1>id {props.match}</h1>
  8. </div>
  9. )
  10. interface RecipeContainerProp extends RouteComponentProps {
  11. routes: {
  12. path: string,
  13. component: ReactType<any>
  14. }[]
  15. };
  16. const RecipesContainer = (props: RecipeContainerProp) => {
  17. return (
  18. <div>
  19. <Route
  20. exact
  21. path={props.match.path}
  22. component={RecipeList}
  23. />
  24. {
  25. props.routes.map((route: any, i: number) => (
  26. <Route
  27. key={i}
  28. path={route.path}
  29. component={route.component}
  30. />
  31. ))
  32. }
  33. </div>
  34. )
  35. }
  36. export default RecipesContainer;