React-native-testing-library: Any way of triggering the onValueChange event of a Picker element?

Created on 2 Jul 2019  Â·  4Comments  Â·  Source: callstack/react-native-testing-library

Describe the Feature

Not a feature request per se. Just wanted to ask if there's a recommended way of calling the onValueChange event on the Picker element

question

Most helpful comment

Describe the Feature

Not a feature request per se. Just wanted to ask if there's a recommended way of calling the onValueChange event on the Picker element

Ever solved that? I get TypeError: Cannot read property 'charAt' of undefined when I do fireEvent(pickerItem, 'onValueChange', {someData})

All 4 comments

Hey! There's no recommended way. You should be good using something like:

fireEvent(pickerItem, 'onValueChange', {someData})

Describe the Feature

Not a feature request per se. Just wanted to ask if there's a recommended way of calling the onValueChange event on the Picker element

Ever solved that? I get TypeError: Cannot read property 'charAt' of undefined when I do fireEvent(pickerItem, 'onValueChange', {someData})

So far we're just mocking the Picker component with a TextInput, but it's messy. I have to translate the onChange call to pass an index into the callback. Would be great to know if someone has a specific example of selecting the Picker control and calling fireEvent to manipulate it.

I think I have got it to work. I will check and update you.

On Fri, Sep 11, 2020, 5:11 PM Luke Williams notifications@github.com
wrote:

So far we're just mocking the Picker component with a TextInput, but it's
messy. I have to translate the onChange call to pass an index into the
callback. Would be great to know if someone has a specific example of
selecting the Picker control and calling fireEvent to manipulate it.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/callstack/react-native-testing-library/issues/197#issuecomment-691153055,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALF7AKDNP7PYBYVG4537PQDSFI4ZXANCNFSM4H42EDXQ
.

Was this page helpful?
0 / 5 - 0 ratings