Skip to content

Commit d0c69fe

Browse files
committed
fix: button display [Object Object] after setState on select.
1 parent 3e7f9e0 commit d0c69fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/ModalDropdown.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class ModalDropdown extends Component {
9191
componentWillReceiveProps(nextProps) {
9292
let {buttonText, selectedIndex} = this.state;
9393
const {defaultIndex, defaultValue, options} = nextProps;
94-
buttonText = this._nextValue == null ? buttonText : this._nextValue.toString();
94+
buttonText = this._nextValue == null ? buttonText : this._nextValue;
9595
selectedIndex = this._nextIndex == null ? selectedIndex : this._nextIndex;
9696
if (selectedIndex < 0) {
9797
selectedIndex = defaultIndex;
@@ -373,10 +373,11 @@ export default class ModalDropdown extends Component {
373373
const {onSelect, renderButtonText, onDropdownWillHide} = this.props;
374374
if (!onSelect || onSelect(rowID, rowData) !== false) {
375375
highlightRow(sectionID, rowID);
376-
this._nextValue = rowData;
376+
const value = renderButtonText && renderButtonText(rowData) || rowData.toString();
377+
this._nextValue = value;
377378
this._nextIndex = rowID;
378379
this.setState({
379-
buttonText: renderButtonText && renderButtonText(rowData) || rowData.toString(),
380+
buttonText: value,
380381
selectedIndex: rowID
381382
});
382383
}

0 commit comments

Comments
 (0)