1

I'm trying to extend the react-native TextInput (RCTTextField/RCTTextFieldManager) that I'm able to pass a react component (e.g. <Picker >...</Picker>) as an attribute (e.g. input) that will be set as the UITextInputs inputView attribute.

I'd expect to be able to pass a react component as a property to a native component as follows:

RCTTextFieldManager.m:

RCT_EXPORT_VIEW_PROPERTY(input, UIView)

Form.js

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

This results in the following error:

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>"
)

(How) is it possible to pass a react component as a property to a native component?

4

1 回答 1

0

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

于 2016-06-05T05:46:51.403 回答