skratchdot / react-bootstrap-multiselect

A multiselect component for react (with bootstrap). This is a react port of bootstrap-multiselect.
http://projects.skratchdot.com/react-bootstrap-multiselect/
Other
119 stars 61 forks source link

Reloading options based on events #10

Open ajeyak opened 9 years ago

ajeyak commented 9 years ago

React calls render() when the state of the component changes. If a component uses this Multiselect widget and repaints itself when the web server responds with options for the dropdown, this multiselect does not repaint itself. The alternative is to implement the React component's componentDidMount() and call $.multiselect("dataprovider", options) inside it. This is straying from react's principles. Is this a known bug?

skratchdot commented 9 years ago

Yes, it's a known limitation. This component was a lazy solution to a React project I was working on (and doesn't follow React's prop/state principles). See: https://github.com/skratchdot/react-bootstrap-multiselect/pull/8

Someone added a syncData method which might do what you want. I tried a few methods of updating the options on every render(), but would always run into weird behavior. For this component to follow React principles correctly, I'd either need to rewrite the base/upstream library completely, or get a few pull requests merged into the base library.

ajeyak commented 9 years ago

Thanks for responding! syncData() works and I can move on for now. This is a great widget and it would be really nice if it adheres more closely to react's principles, but I understand what you're saying.