React-native-collapsible: (Accordion) Render content on header click

Created on 31 Jan 2018  路  6Comments  路  Source: oblador/react-native-collapsible

My use case is that I have to render a lot of data from the server. That said - is there an option to load the data on demand - i.e. to render the headers in the Accordion and when the user clicks on one header to load data from server for that specific header. Something like onHeaderClicked method:

                   <Accordion
                        sections={sections}
                        renderHeader={this._renderHeader}
                        onHeaderClicked={this._onHeaderClicked}
                    />
help wanted awaiting-reply

All 6 comments

Will look into this on the weekend

@iRoachie Did you have some time to look into this?
It would be really helpful because if each section contains a lot of content and the user will not always open each section to see its content - it is unnecessary to retrieve the whole data from a server when rendering the screen.

Not as yet i鈥檓 afraid. Been pretty bogged down at work. Will try to block off Tuesday evening to look through the issues

Hey @alexstoyanov so I've got a solution that doesn't need to change anything in the api. You simply just have to put the sections array in your state, and then update in the onChange callback.

Here's an example video I made:

https://www.useloom.com/share/e97dde841afb404da3bda216d17becd1

Closing this as inactive. If the solution didn't work for you let me know.

@iRoachie - I know this is an old post, but this worked great for me. Thank you!

Was this page helpful?
0 / 5 - 0 ratings