Comments (12)
Hi @sohobloo firstly, thanks for the component. But I am facing the same issue as @Stoffern. I have provided a function to generate the view required for renderRow. However, after the row is selected, the name displayed is [object Object]
. This is the code I am using:
<ModalDropdown options={collection} renderRow={(row) => displayRow(row)} onSelect={...} />
const displayRow = (data) => {
return (
<TouchableHighlight>
<View style={styles.row}>
<Image source={{ uri: data.image}} style={styles.photo} />
<Text style={styles.selectedFont}>{`${data.name} (${data.age})`}</Text>
</View>
</TouchableHighlight>
)
}
Do you see anything wrong here? Ignore the onSelect function.
from react-native-modal-dropdown.
As I mentioned in this commit 9f3bc08
Be sure to render your own trigger or I don't know what text to display
on it.
from react-native-modal-dropdown.
Yes. I don't know the data structure of your array so you have to do the work on your own renderRow.
from react-native-modal-dropdown.
it should implemented a function for the render of the current element.
As your example and docs provide information that points to Objects can be used.
from react-native-modal-dropdown.
I think it's the same for developers to just use renderRow
to do it.
Or I missunderstand what you mean?
from react-native-modal-dropdown.
@Amila17 @Stoffern
Sorry, now I understand what is your problem.
Maybe I shoud provide a prop like getText
for someone who use object array as options to return the text to display. Or specify the object MUST have a name
property for me to show.
Right now, the workaround is that you can render your own button and use this component as the wrapper.
from react-native-modal-dropdown.
@sohobloo yeap, that makes sense now. For the moment I will use the workaround you have mentioned above. But I guess it would be better to specify a property like modalDropDownName
when providing object array's as a source. This would make things cleaner.
Thanks for the response 👍
from react-native-modal-dropdown.
@Amila17 can you show me how you solved this problem?
Im having the same problem with data fetched from json array. But I don't know how to render my own button and use it as wrapper.
@sohobloo any help?
from react-native-modal-dropdown.
我觉得他的意思就是用object类型的array作为数据放入 options里面不能使用,因为 没有类似 picker组建的 selectedValue 和 onvaluechange, 当用objectArray作为options,你选择某个选项上面只会显示{object,object} 不能正常显示 object的 key 或 value
from react-native-modal-dropdown.
我现在就碰到了这个问题~显示{object,object} 。看来得自己改下了。
from react-native-modal-dropdown.
传入对象的时候显示[object object]这个到底咋解决啊,一脸懵逼
from react-native-modal-dropdown.
from react-native-modal-dropdown.
Related Issues (20)
- Fork with latest PR's merged HOT 2
- is it possible to add the icon on the right of the default value? HOT 4
- Freeze Android HOT 1
- Any possibility to detect onReachEnd options? HOT 1
- This project is working but seems outdated. Which fork to use? HOT 26
- Search bar feature HOT 1
- New Feature : Display selected Item in the Modal as it is in renderItem HOT 2
- a error in the react native 0.63 HOT 11
- Handle Press Error ModalDropdown HOT 1
- Is this library no longer maintained ? HOT 4
- zIndex visibility problem HOT 1
- filter not work without schroll
- Passing props to the rendered FlatList instance
- Getting Scroll to index error HOT 3
- on change of options how can I rerender renderButtonText and empty it's value inside dropdown?
- Error on web HOT 4
- app crashed when press on dropDownmodal HOT 4
- renderButtonComponent or renderRightComponent does not exist in ModalDropdownProps in latest version HOT 1
- How can i use methods show and hidden?
- Z index issue of the dropdown if placed in a view
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-modal-dropdown.