How do I get the index of each rendered accordion? It doesn't seem to be an argument passed to renderHeader or renderContent.
@devonhuangcodes Use the property 'expanded' of Accordion to get and expand the index of Accordion set upon as in
<Accordion dataArray={dataArray} expanded={1}/>
See NativeBase Docs for Accordion http://docs.nativebase.io/Components.html#accordion-def-headref
I know of that "expanded" property already but I can't seem to think of a way to use that to close an individual accordion or all of the accordions. For example, when a user opens the accordion and clicks away to a different UI component such as a search bar I want the open accordion to close. Is this possible?
same issue, this should be able to be programatically closed. it seems the property does not re-render?
any solution to this problem, issue seems to have closed without resolution. I tried changing the index using state but it does re render & always shows the same expanded row
If your data is set up in a way that allows it - you can use findIndex to get the index by title like so:
renderHeader={(title, expanded) => {
let thisIndex = dataArray.findIndex(d => d.title == title)
}
How can I get item's index from renderHeader and renderContent? @shanekoss's solution is working, but it is not good, what if I have 1 000 000 rows? have to find every time? performance will be bad
How can I get item's index from renderHeader and renderContent? @shanekoss's solution is working, but it is not good, what if I have 1 000 000 rows? have to find every time? performance will be bad
I would recommend you to preferably build ur own accordion because this one has lots of issues and they don't get closed either. The easier workaround is stop beating around the bush with libraries construct ur own saves a lot of time than going thru all this pain.
@mdmoin7 Thanks, which I am going to do is stop using this components, too much pain
Hello everyone,
I have created a PR adding the feature of getting Header index and Content index
Here is the PR Link
https://github.com/GeekyAnts/NativeBase/pull/3182
and Here is the PR Link in native-base-docs
https://github.com/GeekyAnts/native-base-docs/pull/254
Hope for support of you guys, It is going to be my First Open source Contribution
Most helpful comment
@mdmoin7 Thanks, which I am going to do is stop using this components, too much pain