我收到了一個將List作爲道具的React Functional組件。當在對象上設置默認值時,Flow缺少道具驗證
const Dashboard = (props: { items: List } = { items: List() }) => {
const { items } = props
...
})
然而,items
在const { items } = props
產生以下錯誤:
error 'items' is missing in props validation react/prop-types
的FlowType docs舉個例子:
ES2015 features Default values assigned to parameters must come after the parameter’s type annotation:
function foo (P1: T1 = V): U { .. }
但如何適用它不是真正清楚,我物件
很酷!非常感謝您指出這一點。我會去壓制這個錯誤。 – Dani
不客氣:) –