反应本机:自定义组件将组件作为属性传递



我正在尝试扩展我能够传递反应组件的 react-native TextInputRCTTextField/RCTTextFieldManager )(例如 <Picker >...</Picker> ) 作为属性(例如 input ),将设置为UITextInputinputView属性。

我希望能够将反应组件作为属性传递给本机组件,如下所示:

RCTTextFieldManager.m:

RCT_EXPORT_VIEW_PROPERTY(input, UIView)

形式.js

render() {
  return (
    <TextInput input={<Picker>...</Picker>} />
  )
}

这会导致以下错误:

2016-06-04 22:17:50.537 [fatal][tid:com.facebook.react.ShadowQueue] Exception '*** -[__NSArrayM insertObject:atIndex:]: index 3 beyond bounds [0 .. 1]' was thrown while invoking manageChildren on target RCTUIManager with params (
    9,
    "<null>",
    "<null>",
        (
        98
    ),
        (
        3
    ),
    "<null>"
)

(如何)是否可以将反应组件作为属性传递给本机组件?

在我看来,更好的方法是自定义自己的UITextInput,并使用像inputType这样的属性来决定应该显示哪个输入视图。