问题描述
我基本上是从文档中复制/粘贴示例
<Select
selectedindex={this.currLangIndex}
onSelect={(index) => {
this.currLangIndex = index;
}}>
<SelectItem title="Option1" />
<SelectItem title="Option2" />
</Select>
,我收到以下错误消息:
TypeError: undefined is not an object (evaluating 'props.getItem')
This error is located at:
in FlatList (created by List)
in List (created by Context.Consumer)
in Wrapper (created by List)
in List (created by Autocomplete)
in RCTView (at View.js:34)
in View (created by PopoverView)
in RCTView (at View.js:34)
in View (created by PopoverView)
in PopoverView (created by Context.Consumer)
in Wrapper (created by PopoverView)
in PopoverView
in UnkNown
in RCTView (at View.js:34)
in View (created by ModalResolver)
in ModalResolver (created by ModalPanel)
in RCTView (at View.js:34)
in View (created by ModalPanel)
in ModalPanel (created by ApplicationProvider)
in ThemeProvider (created by StyleProvider)
in MappingProvider (created by StyleProvider)
in StyleProvider (created by ApplicationProvider)
in ApplicationProvider (at app.tsx:65)
in App (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
我是React Native和UI Kitten的新手,所以能获得任何帮助。
解决方法
const [selectedIndex,setSelectedIndex] = useState(new IndexPath(0));
<Layout style={styles.container} level='1'>
<Select
selectedIndex={selectedIndex}
onSelect={index => setSelectedIndex(index)}>
<SelectItem title='Option 1'/>
<SelectItem title='Option 2'/>
<SelectItem title='Option 3'/>
</Select>
</Layout>
我遇到了同样的问题,但是当用Layout Comp包裹它时它起作用了。从UI Kitten中获取,但现在尝试选择时未显示任何选项