我正在尝试使用react-native获取新的Algolia react- instantsearch组件。
我一直在遵循指南,但完全陷入困境。
基本上,每当我尝试将<SearchBox />
组件添加到<InstantSearch />
组件中时,我的应用程序都会以Expected组件类终止,并获得[object Object]。
至于我可以告诉大家,我连接最多<SearchBox />
的connectSearchBox
连接器,所以我不知道发生了什么事。
代码(我确实具有appId,apiKey和index的真实值):
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ListView,
TextInput,
Image,
} from 'react-native';
import {InstantSearch} from 'react-instantsearch/native';
import {connectSearchBox} from 'react-instantsearch/connectors';
import * as Styles from '../../styles/';
const SearchBox = connectSearchBox(({currentRefinement, refine}) =>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => refine(text)}
value={currentRefinement}
/>);
export default class InfiniteSearch extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.container}>
<InstantSearch
className="container-fluid"
appId="appId"
apiKey="apiKey"
indexName="indexName"
>
<SearchBox />
</InstantSearch>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
padding: 10,
},
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句