I am using maybe in React Native, in the props of a custom text component. The custom component should set the underlying Text component prop numberOfLines to 1 by default, or null if the user passes false into the custom component's truncate prop:
<BasicText
numberOfLines={maybe(props.truncate)
.filter(t => !t)
.map(() => null)
.orJust(1)}
/>
However, flow understandably complains about returning null in .map():
null (This type is incompatible with union: number | boolean | string | object type | array type
See also: call of method `map`
Is there an "idiomatic" way to handle this, or is it simply a case of putting an // $ExpectError comment and forgetting about it?
I am using
maybein React Native, in the props of a custom text component. The custom component should set the underlyingTextcomponent propnumberOfLinesto1by default, ornullif the user passesfalseinto the custom component'struncateprop:However, flow understandably complains about returning
nullin.map():Is there an "idiomatic" way to handle this, or is it simply a case of putting an
// $ExpectErrorcomment and forgetting about it?