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

ReactiveBase doesn't update props dynamically #373

Closed divyanshu013 closed 6 years ago

divyanshu013 commented 6 years ago

Issue Type:

Bug

Platform:

Web

Description:

When trying to update the type of the Elasticsearch via the prop, it doesn't update dynamically (when the component re-renders).

<ReactiveBase
  ...
  type={type} // doesn't picks updates
>
  ...
</ReactiveBase>

Reactivesearch version: 2.6.2

miukimiu commented 6 years ago

Hello, The same happens with the app={app} prop. If I try to rerender the <ReactiveBase /> based on the app prop change nothing happens.

If I try something like this:

class ReactiveBaseContainer extends Component {
  shouldComponentUpdate(nextProps) {
    const differentIndex = this.props.app !== nextProps.app;
    return differentIndex;
  }

  render() {
    return (
      <ReactiveBase
        app={this.props.app}
        url="https://someUrl.com"
      >
        {this.props.children}
      </ReactiveBase>
    );
  }
}

export default ReactiveBaseContainer;

The render is called and the props.app changed but it always displays the first render.

Do you have an estimation of how long it will take to fix this bug?

Thanks!

metagrover commented 6 years ago

Fixed here - c79c60f. We will roll this out in the upcoming release today. 🎉

Please note that we don't recommend updating the ReactiveBase's props in general (unless you know what you're doing), as it requires us to reset the internal reactivesearch-redux-store and remount all the underlying components in order to fetch the relevant data.

miukimiu commented 6 years ago

Thanks! It was really fast!

The problem is the data that I'm using comes from two different elasticSearch index. So I'm trying to use a dropdown where I can pick the index that I want to search:

screen shot 2018-06-05 at 1 06 47 pm

Not sure if there is a better way of doing this without updating the ReactiveBase's props. Any suggestions?

metagrover commented 6 years ago

Given your use-case, it makes perfect sense to update the ReactiveBase's props 👍

PS: The UI looks great. We would love to hear your feedback/thoughts on using reactivesearch in production. 🐱

metagrover commented 6 years ago

Released in v2.6.6