Code Monkey home page Code Monkey logo

Comments (12)

Amila17 avatar Amila17 commented on July 29, 2024 2

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.

sohobloo avatar sohobloo commented on July 29, 2024 1

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.

sohobloo avatar sohobloo commented on July 29, 2024

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.

st0ffern avatar st0ffern commented on July 29, 2024

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.

sohobloo avatar sohobloo commented on July 29, 2024

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.

sohobloo avatar sohobloo commented on July 29, 2024

@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.

Amila17 avatar Amila17 commented on July 29, 2024

@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.

andreecosta avatar andreecosta commented on July 29, 2024

@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.

kidolee avatar kidolee commented on July 29, 2024

我觉得他的意思就是用object类型的array作为数据放入 options里面不能使用,因为 没有类似 picker组建的 selectedValue 和 onvaluechange, 当用objectArray作为options,你选择某个选项上面只会显示{object,object} 不能正常显示 object的 key 或 value

from react-native-modal-dropdown.

cliang0917 avatar cliang0917 commented on July 29, 2024

我现在就碰到了这个问题~显示{object,object} 。看来得自己改下了。

from react-native-modal-dropdown.

dengshasha avatar dengshasha commented on July 29, 2024

传入对象的时候显示[object object]这个到底咋解决啊,一脸懵逼

from react-native-modal-dropdown.

sohobloo avatar sohobloo commented on July 29, 2024

#122 (comment)

from react-native-modal-dropdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.