Javascript 如何正确使用React.FunctionalComponent<;道具>;关于无状态功能组件?
我需要为react无状态功能组件添加流注释。 因此,对于文档,我应该使用Javascript 如何正确使用React.FunctionalComponent<;道具>;关于无状态功能组件?,javascript,flowtype,Javascript,Flowtype,我需要为react无状态功能组件添加流注释。 因此,对于文档,我应该使用React.StatelessFunctionalComponent 签名如下: 键入无状态FunctionalComponent=(props:props)=> 反应节点 但我收到好几封信 我做错了什么?为什么 /@flow 从“React”导入*作为React 从“时刻”导入时刻 从“../../shared/icon/IconWeather”导入IconWeather /*eslint禁用无未定义*/ 类型Props
React.StatelessFunctionalComponent
签名如下:
键入无状态FunctionalComponent=(props:props)=>
反应节点
但我收到好几封信
我做错了什么?为什么
/@flow
从“React”导入*作为React
从“时刻”导入时刻
从“../../shared/icon/IconWeather”导入IconWeather
/*eslint禁用无未定义*/
类型PropsType={
+日期:年月日,
+tempMin:数字,
+tempMax:数字,
+iconCode:number,
+天气描述:字符串
}
/*eslint启用无未定义*/
const ForecastDay=({date,tempMin,tempMax,iconCode,weatherDescription}:PropsType):React.statelementalFunctionalComponent=>{
const dateFormat=moment.unix(date.format('ddd,MMM D'))
const tempMinRounded=Math.round(tempMin)
const tempMaxRounded=Math.round(tempMax)
返回(
{dateFormat}
{tempMinRounded}°;
{tempMaxRounded}°;
{weatherDescription}
)
}
导出默认预报日
我通过添加
const ForecastDay:React.StatelessComponent<PropsType>
const ForecastDay:React.statelements组件
并用作返回类型ReactElement
或React.Element
/@flow
从“React”导入*作为React
从“时刻”导入时刻
从“../../shared/icon/IconWeather”导入IconWeather
/*eslint禁用无未定义*/
类型PropsType={
+日期:年月日,
+tempMin:数字,
+tempMax:数字,
+iconCode:number,
+天气描述:字符串
}
/*eslint启用无未定义*/
const ForecastDay:React.statelement=({date,tempMin,tempMax,iconCode,weatherDescription}:PropsType):ReactElement=>{
const dateFormat=moment.unix(date.format('ddd,MMM D'))
const tempMinRounded=Math.round(tempMin)
const tempMaxRounded=Math.round(tempMax)
返回(
{dateFormat}
{tempMinRounded}°;
{tempMaxRounded}°;
{weatherDescription}
)
}
导出默认预报日
我通过添加
const ForecastDay:React.StatelessComponent<PropsType>
const ForecastDay:React.statelements组件
并用作返回类型ReactElement
或React.Element
/@flow
从“React”导入*作为React
从“时刻”导入时刻
从“../../shared/icon/IconWeather”导入IconWeather
/*eslint禁用无未定义*/
类型PropsType={
+日期:年月日,
+tempMin:数字,
+tempMax:数字,
+iconCode:number,
+天气描述:字符串
}
/*eslint启用无未定义*/
const ForecastDay:React.statelement=({date,tempMin,tempMax,iconCode,weatherDescription}:PropsType):ReactElement=>{
const dateFormat=moment.unix(date.format('ddd,MMM D'))
const tempMinRounded=Math.round(tempMin)
const tempMaxRounded=Math.round(tempMax)
返回(
{dateFormat}
{tempMinRounded}°;
{tempMaxRounded}°;
{weatherDescription}
)
}
导出默认预报日