I didn’t know this, but functions with @react.component
can’t return an option<React.element>
?
This is documented?
If I comment out line 18 there is no type error
module RightSidebar = {
@react.component
let make = (~items: array<string>) => {
switch items->Js.Array2.length > 0 {
| true =>
items
->Js.Array2.map(item => item->React.string)
->React.array
->Some
| false => None
}
}
}
module App = {
@react.component
let make = () => {
let a = <RightSidebar items=[] />
<h1> {"Menu"->React.string} </h1>
}
}