1
現在、私は、オブジェクトの非構造(インライン)FlowTypeとES6を使用して簡潔にオブジェクトの非構造化に注釈を付けるにはどうすればよいですか?
に注釈を付けるために、次のコードを使用しています私は、インラインアノテーションを使用することなく、例えば、そこにあれば、より簡潔な形を知っていただきたいと思います。
私に例を教えてください。
// @flow
import React from 'react'
import moment from 'moment'
import IconWeather from '../../shared/icon/IconWeather'
const ForecastDay = ({ date, tempMin, tempMax, iconCode, weatherDescription }:{+date:Date, +tempMin: number, +tempMax: number, +iconCode:string, +weatherDescription:string }) => {
const dateFormat = moment.unix(date).format('ddd, MMM D')
const tempMinRounded = Math.round(tempMin)
const tempMaxRounded = Math.round(tempMax)
return (
<div>
<div>{dateFormat}</div>
<div>
<IconWeather code={iconCode} />
</div>
<div>
<div>
{tempMinRounded}°
</div>
<div>
{tempMaxRounded}°
</div>
</div>
<div>
{weatherDescription}
</div>
</div>
)
}
export default ForecastDay