我正在尝试使用react本地的新的Algolia 反应-瞬间搜索组件。
我一直在跟踪指南,我完全被困住了。
基本上,每当我试图将我的<SearchBox />组件添加到<InstantSearch />组件中时,我的应用程序就会出现一个预期的组件类,GETObjectObject。
据我所知,我正在将<SearchBox />连接到connectSearchBox连接器,所以我不确定发生了什么。
代码(我确实有appId、apiKey和索引的实际值):
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,
},
});发布于 2016-12-16 12:07:47
发布于 2016-12-09 17:02:01
尝试将TextInput包装在SearchBox中:
const SearchBox = connectSearchBox(({currentRefinement, refine}) => (
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => refine(text)}
value={currentRefinement}
/>
));https://stackoverflow.com/questions/41064940
复制相似问题