2017-02-26 296 views
1

我使用的是阿尔戈利亚反应即时搜索,并且我有要求在每次有结果时显示重叠。React即时搜索:onSearchStateChange获取返回的匹配数

所以我想通过algolia提供的onSearchStateChange函数来处理它。但我仍然困惑从哪里获得总点击。我已经有了一个想法,就像使用通过jquery提取数字显示的结果一样。但我不想这样做。有没有其他方式可以建议?

onSearchStateChange(nextState) { 

    //must get the number of total hits. 

    nextState = cleanDeep(nextState); 
    let filters = transformer(nextState); 
    this.setState({ 
     searchState: nextState, 
     filters: filters, 
     searchChanged: true 
    }) 
    this.sendToAti(filters); 

    this.addOverlay(); // <--- function that will show the overlay. 

    location.hash = qs.stringify(nextState); 
} 

回答

3

onSearchStateChange功能不包含searchResults对象,你可以找到的点击次数。

但是,我们提供了一个<Stats>小部件和一个connectStats连接器,其中包含此信息。也许你可以使用它?