appbaseio / reactivesearch

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

Dynamic Slider no way to handle error #2015

Closed sunnyunde-xooa closed 2 years ago

sunnyunde-xooa commented 2 years ago

Affected Projects React

Library Version: 3.34.3

Describe the bug When using the Dynamic Range Slider as component for search filter. If no data is present in the index or provided with incorrect field, it goes in infinite loop. Due to no way to handle the error on the component not able to do control the error.

To Reproduce Code sanbox link: https://codesandbox.io/s/clever-glitter-wco6kt?file=/src/index.js Steps to reproduce the behavior: Add a Dynamic Slider component with incorrect field or create a index with no data. Disable enableAppbase

Expected behavior If no data is present or field provided is incorrect a proper error to be thrown and way to handle error in this component.

Screenshots

Desktop (please complete the following information):

Additional context Uncaught Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

NOTE: If this issue is fixed please share the link to the solution. Thank You.

ubaranzorlu commented 2 years ago

I have been trying to dodge this for a long time. I think it is because my elastic search returns aggregation buckets as follows which is null instead of numerical values

"aggregations": {
    "min": {
        "value": null
    },
    "max": {
        "value": null
    }
}
image

and I got this as a bonus

image
ubaranzorlu commented 2 years ago

I have solved this error by putting my fork of appbaseio-apps/reactivesearch-proxy-server in between elastic server and the reactivesearch. There I have a response middleware where I replace null min with 0 and null max with a float 2.147483647 so that I can catch it later on the front-end and handle the situation by disabling this filter.

sunnyunde-xooa commented 2 years ago

Yes, Handling it with help of middleware solved the issue. Thanks @ubaranzorlu.