1
我试图将流实现到我的React应用程序中。到目前为止它工作正常,但我遇到了默认值的问题。React无状态组件上的流类型别名
函数头是:
const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
为TFormControls类型别名是:
type TFormControls = {
onSubmit?: boolean,
onReset?: boolean,
onClear?: boolean
}
我所期望的,因为我把也许运营商那里controls: ?TFormControls
,它要么是我的type-alias或null/undefined,但流程告诉我:
src/components/forms/FormControls.jsx:35
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ null. This type is incompatible with
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ object type
src/components/forms/FormControls.jsx:35
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ object type. This type is incompatible with
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ null
任何指针wo非常欢迎!
编辑:按照要求,错误的完整功能的example
你可以发布一个完整的例子吗?这会让那些试图帮助你的人更容易。你甚至可以在http://flowtype.org/try中发布一个链接 –