react-typeahead
react-typeahead copied to clipboard
defaultValue doesn't update after re-render
I have Typeahed object with defaultValue prop. In componentDidMount I receive new value and call setState but defaultValue doesn't change.
same problem here
You may be falling for https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html . There's an unofficial API for setting the text: https://github.com/fmoo/react-typeahead/blob/master/src/typeahead/index.js#L108 I don't exactly know how it works in your case for componentDidMount, but for componentDidUpdate, something like this should work:
componentDidUpdate (prevProps, prevState){
if (this.props.text != prevProps.text) { this.refs.MyTokenizer.setEntryText(this.props.text);}
}
I'd love a readme update PR if you get that working.