【发布时间】:2019-03-17 19:15:24
【问题描述】:
好吧,我看到了下面的代码 sn-p,我想知道type Props 到底是什么?跟流量有关系吗?还是与道具类型有关?
如何在定义为类的组件中使用它?
我在此处找到的 React-Router 示例中看到了它:https://atlaskit.atlassian.com/packages/core/navigation
代码sn-p:
// @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;
【问题讨论】:
-
跟道具类型有关。您为收到的每个属性定义数据类型,或者在反应中发送任何内容
标签: javascript reactjs atlaskit