Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderButtonText does not work #127

Closed
Mexxerio opened this issue Jan 22, 2018 · 13 comments
Closed

renderButtonText does not work #127

Mexxerio opened this issue Jan 22, 2018 · 13 comments
Labels

Comments

@Mexxerio
Copy link

The newly added renderButtonText property does not work. The function gets called after an option is selected, but it doesn't correctly set the button text. It still shows [object Object].

@IvanIvaschenko
Copy link

@Mexxerio Check your package.json. And change "react-native-modal-dropdown": "^0.5.0" to "^0.6.0".

@Mexxerio
Copy link
Author

@IvanIvaschenko It already is on ^0.6.0. I specifically updated it to use that new feature.

@IvanIvaschenko
Copy link

@Mexxerio find the module in node_modules. Open ModalDropdown and look on line 361 you should see this string buttonText: renderButtonText && renderButtonText(rowData) || rowData.toString(). If no try to restart packager.

@Mexxerio
Copy link
Author

@IvanIvaschenko It's there.

@IvanIvaschenko
Copy link

@Mexxerio share your code.

@atul-forbinary
Copy link

is this library work both ios and android , i am still getting [object object ]

@mrkirchner
Copy link

mrkirchner commented Jan 30, 2018

I am also getting this issue as well. Here is a snippet of my code I continue to get [object object] and i double checked that im on version ^0.6.0.

selectChangeHandler = (index, facility) => {
  this.props.selectChangeHandler(facility);
};

const renderPrompt = (rowData) => {
  return rowData.name;
};

<ModalDropdown ref={el => this.dropdown = el}
                       options={this.props.options}
                       renderButtonText={renderPrompt}
                       renderRow={rowRender}
                       onSelect={this.selectChangeHandler}/>

Dug around a bit more if i remove the onSelect from ModalDropdown the renderButtonText works.

@IvanIvaschenko
Copy link

@atul-forbinary @mrkirchner You can use dirty hack.
const Languages = [
{ value: 'English', source: require('../../../assets/gb.png'), locale: 'en' },
{ value: 'Espanol', source: require('../../../assets/es.png'), locale: 'es' },
{
value: 'Francais',
source: require('../../../assets/fr.png'),
locale: 'fr'
},
{
value: 'Portuguese',
source: require('../../../assets/pt.png'),
locale: 'pt'
},
{ value: 'Deutsch', source: require('../../../assets/de.png'), locale: 'de' },
{ value: 'Italiano', source: require('../../../assets/it.png'), locale: 'it' }
]

<ModalDropdown
options={Languages.map(item => item.value)}
textStyle={[styles.text, styles.regularText]}
style={styles.dropdown}
onSelect={(indx, value) => this.onSelect(value, indx)}
dropdownTextStyle={[styles.text, styles.dropdownText]}
dropdownStyle={styles.dropdownStyle}
defaultValue={this.state.lang}
renderRow={this.renderRow.bind(this)}
/>

onSelect = async (value, indx) => {
let Lang = Languages[indx]
...
}

@mrkirchner
Copy link

mrkirchner commented Jan 31, 2018

@IvanIvaschenko Not sure what your trying to show here. Anytime i try to setState or call a props.function in my selectHandler it will not work.

@sohobloo Any suggestions on whats going on or is it a bug? Doing a quick look at your js it seems like renderButtonText is only being used onPress does it also need to happen on select(idx) or componentWillReceiveProps?

Issue only occurs on a a onSelect Function which contains a setState in it. I assume its because setState is asynchronous but not sure of a way around that.

@mrkirchner
Copy link

Opened an MR #131 not sure if that is best way to fix things. Still learning react ...

@sohobloo
Copy link
Owner

sohobloo commented Feb 9, 2018

This issue has been fixed. Please update to v0.6.1

Sorry, my fault and thanks to @swb2016(#128)
and also thanks to @mrkirchner

@sohobloo sohobloo added the bug label Feb 9, 2018
@sohobloo sohobloo closed this as completed Feb 9, 2018
@Culzean
Copy link

Culzean commented Feb 22, 2018

I am also still finding this issue, I have version 0.6.1

@brascene
Copy link

@sohobloo same here, 0.6.1 version and still hitting the [object] thing, why is this so tough to get working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants