好吧,我看到了下面的这段代码片段,我想知道到底type Props
是什么?跟流量有关系吗?还是与道具类型有关?
如何在定义为类的组件中使用它?
我在此处找到的 React-Router 示例中看到了它:https ://atlaskit.atlassian.com/packages/core/navigation
代码片段:
// @flow
import React from "react";
import { AtlassianIcon } from "@atlaskit/logo";
import Lorem from "react-lorem-component";
import Page from "@atlaskit/page";
import Navigation, { AkContainerTitle } from "@atlaskit/navigation";
import RouterLinkComponent from "./RouterLinkComponent";
import RouterLinkItem from "./RouterLinkItem";
// @flow
type Props = {
title: string,
currentPath: string
};
const PageNavigation = ({ title, currentPath }: Props) => (
<Page
navigation={
<Navigation
containerHeaderComponent={() => (
<AkContainerTitle
href="/iframe.html"
icon={<AtlassianIcon label="atlassian" />}
linkComponent={RouterLinkComponent}
text="Dashboard"
/>
)}
globalPrimaryIcon={<AtlassianIcon label="Home" size="small" />}
globalPrimaryItemHref="/iframe.html"
linkComponent={RouterLinkComponent}
>
<RouterLinkItem
text="Page 1"
to="/page1"
isSelected={currentPath === "/page1"}
/>
<RouterLinkItem
text="Page 2"
to="/page2"
isSelected={currentPath === "/page2"}
/>
<RouterLinkItem
text="Page 3"
to="/page3"
isSelected={currentPath === "/page3"}
/>
<RouterLinkItem
text="Page 4"
to="/page4"
isSelected={currentPath === "/page4"}
/>
</Navigation>
}
>
<div>
<h1>{title}</h1>
<Lorem count="30" />
</div>
</Page>
);
export default PageNavigation;