React-native-collapsible: Adding to the touchableProps onPress functionality?

Created on 19 Oct 2019  路  4Comments  路  Source: oblador/react-native-collapsible

What I'm Trying To Do:

I want to add on to the onPress of the components in the accordion, but using "touchableProps" and defining a onPress event, removes the functionality of opening them up.

Why I'm Doing this?

I want onPress to trigger another event, other than opening the accordion.

What I've tried:

    <Accordion
        touchableProps={{ onPress () {
        console.log('test')}}}
    />

This logs test, but no longer opens the accordions. Is there any way I can have onPress do multiple things?

question

Most helpful comment

See this video i made on how to do this using onPress https://www.loom.com/share/e97dde841afb404da3bda216d17becd1

All 4 comments

What's your use case for this? Cause you can put your code in the onChange

Hi iRoachie, thanks for the response! My use case is this:

I have the possibility of about 200+ objects coming through to my accordion view. They get to my code via sockets. The websocket coll to the API for the names of these things is lightning fast. Less than 100ms. However, to get the individual information (each object can contain about 10 or 15 categories of info) it is much slower, as i have to query each object one by one.

So instead of just getting ALL the possible data in one go, I only want to ask the websocket to get the category data, once the user has clicked on a particular object.

Visual example

-car1-
-car2-
-car3-
-boat1-
-airplane6-

//Clicking on one of these will expand it 

-car1-
| make: jeep
| model: cherokee
| year: 1990
| damages?
|| -Front tire blown
|| -radiator broken
| Accident record
-car2-

See this video i made on how to do this using onPress https://www.loom.com/share/e97dde841afb404da3bda216d17becd1

Ah, got it working, thank you!

Was this page helpful?
0 / 5 - 0 ratings