Skip to content

Commit abb3376

Browse files
committed
chore: update readme
1 parent dd170cd commit abb3376

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ You can find them in the example.
1919

2020
## Update History
2121

22+
### v0.6.2
23+
- Fix [#139](https://github.com/sohobloo/react-native-modal-dropdown/issues/139) `renderButtonText` renders \[object Object] if there is a call to `setState` in `onSelect` or `renderButtonText` functions
24+
2225
### v0.6.1
2326
- Fix [#127](https://github.com/sohobloo/react-native-modal-dropdown/issues/127) `renderButtonText` does not work on `select(idx)` (Thanks to [@swb2016](https://github.com/swb2016))
2427
- Code optimization.

example/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)