appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 466 forks source link

onResultStats not getting called if 0 results #520

Closed axeff closed 6 years ago

axeff commented 6 years ago

Issue Type: Bug

Platform: Web

Description: ReactiveList doesn't call onResultStats if there are 0 results. Shouldn't the function still be called and return 0 results? In my case I display the number of results after setting state with value from onResultStats and don't see any changes when my filtering results in 0. I still see last number of results.

Minimal reproduction of the problem with instructions: On codesandbox do filtering and watch Results in <h1>. When clicking on XYZ (which results in 0) the <h1> still shows previous amount of results.

Reactivesearch version: x.y.z 2.8.1

Browser: all

divyanshu013 commented 6 years ago

Duplicate of https://github.com/appbaseio/reactivesearch/issues/454. In short onResultStats is a render function unlike its name which suggests that it's an event handler. We've a PR which will fix this by clearly separating the render prop and the event prop https://github.com/appbaseio/reactivesearch/pull/461

This will be a breaking change and will be out in the next major release ✌️