2016-12-09 34 views
1

我试图使用react-native获得新的Algolia react-instantsearch组件。使用Algolia与react-native进行即时搜索

我一直在关注guide,我完全被卡住了。

基本上,只要我尝试添加<InstantSearch />组件内我<SearchBox />成分,我的应用程序预计组件类死了,得了的翻译:

据我所知,我将<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, 
    }, 
}); 
+0

这肯定与我所看到的导向相匹配?它在哪里说的错误是什么? –

+0

@MattAft堆栈跟踪不指向我的代码中特定的任何东西。以'' - >'createInternalComponent' - >'instantiateReactComponent' - >'peformInitialMount'开始,但是继续进行内部React内容的页面和页面。 –

+0

虽然这肯定是由中的''组件造成的。如果我删除,没有错误。 –

回答

0

尝试在搜索盒包装了TextInput:

const SearchBox = connectSearchBox(({currentRefinement, refine}) => (
    <TextInput 
    style={{height: 40, borderColor: 'gray', borderWidth: 1}} 
    onChangeText={(text) => refine(text)} 
    value={currentRefinement} 
    /> 
)); 
+0

仍会引发相同的错误 –