从自动完成功能中删除冗余

时间:2019-07-19 12:45:14

标签: javascript reactjs search filter algolia

使用algolia进行搜索,当使用algolia的自动完成功能时,我得到了由comedienNomComplet过滤的建议。问题是我想删除此图中显示的comedienNomComplet的冗余:

enter image description here

这是我的文件:autocomplete.js

renderSuggestion(hit) {
    //return <Highlight attribute="comedienNom" hit={hit} tagName="mark" />;
    return <div className="cm-search-item-container" style={{cursor:"pointer"}}>
      {hit.comedienNomComplet}
      <hr style={{border: "0.5px solid #2F4A56"}}/>
    </div> 
  }
render() {
    const { hits, onSuggestionSelected } = this.props;
    const { value } = this.state;
    const inputProps = {
      placeholder: 'Ex: comédien, amical, documentaire…',
      onChange: this.onChange,
      value,
    };

    return (
      <AutoSuggest
        suggestions={hits}
        onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
        onSuggestionsClearRequested={this.onSuggestionsClearRequested}
        onSuggestionSelected={onSuggestionSelected}
        getSuggestionValue={this.getSuggestionValue}
        renderSuggestion={this.renderSuggestion}
        inputProps={inputProps}
      />
    );
  }

我在recherche.js中称呼它:

<InstantSearch
indexName="dev_CastingMachine"
searchClient={searchClient}>
<Autocomplete defaultRefinement={localStorage.getItem("motRechercher")} onSuggestionSelected={this.onSuggestionSelected} />
</InstantSearch>

任何帮助将不胜感激。谢谢

0 个答案:

没有答案