首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Algolia react即时搜索与react本机

使用Algolia react即时搜索与react本机
EN

Stack Overflow用户
提问于 2016-12-09 16:34:25
回答 2查看 966关注 0票数 2

我正在尝试使用react本地的新的Algolia 反应-瞬间搜索组件。

我一直在跟踪指南,我完全被困住了。

基本上,每当我试图将我的<SearchBox />组件添加到<InstantSearch />组件中时,我的应用程序就会出现一个预期的组件类,GETObjectObject

据我所知,我正在将<SearchBox />连接到connectSearchBox连接器,所以我不确定发生了什么。

代码(我确实有appId、apiKey和索引的实际值):

代码语言:javascript
复制
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,
    },
});
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-16 12:07:47

Stack Overflow用户

发布于 2016-12-09 17:02:01

尝试将TextInput包装在SearchBox中:

代码语言:javascript
复制
const SearchBox = connectSearchBox(({currentRefinement, refine}) => (
  <TextInput
    style={{height: 40, borderColor: 'gray', borderWidth: 1}}
    onChangeText={(text) => refine(text)}
    value={currentRefinement}
  />
));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41064940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档