[Accordion] Callback function onOpen / onClose
See original GitHub issueIs there a way to set a callback function when I open or close an item in Accordion? It would be nice to have the index of the opened/closed item and let us being able to do stuff with it.
I tried to achieve such a thing in a custom renderHeader
function:
renderHeader(title, expanded) {
return (
<View onPress={() => console.log(expanded)}>
<Text>{title}</Text>
</View>
)
}
It doesn’t work: the onPress
function is not triggered.
I tried to replace the <View />
by a <TouchableOpacity />
and the onPress
function is triggered ; but the item doesn’t expand anymore.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
jQuery accordion - OnCollapse and OnExpand events
What I'd like is to bind an event on accordion open and accordion close... Actually what I'd like to achieve is to do...
Read more >Angular PrimeNG Accordion Events - GeeksforGeeks
onOpen : It is a callback function called when a tab is opened. onClose: Callback function is called when the active tab is...
Read more >Accordion API - Material UI - MUI
API reference docs for the React Accordion component. Learn about the props, CSS, ... Callback fired when the expand/collapse state is changed. Signature:...
Read more >Accordion Item #2 - React-Bootstrap
Click the accordions below to expand/collapse the accordion content. ... onExit. function. Callback fired before the component collapses. onExited. function.
Read more >Accordion | Mobify DevCenter
Triggered by the user clicking on the opened header ( AccordionItem ). The onClose function is called with the item's ID passed to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I take the sample code provided in the documentation, it would be nice to be abble to have something like this working:
Where
index
is the index of the header pressed anditem
is equivalent todataArray[index]
. It would be great to also have anonOpen()
andonClose()
or even betteronBeforeOpen()
,onAfterOpen()
,onBeforeClose()
,onAfterClose()
.Need this else will have to leave the accordion from native base. very important feature for mobile development