-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Item open & Close when others are selected #39
Comments
You can keep refs to each accordions, and in It would be something like that: //Keep refs in an array
accordionRefs = [];
_renderRow(rowData, sectionID, rowID) {
const header = this.renderHeader(rowData, rowID);
var content = (
<View>
<Text>This content is hidden in the accordion</Text>
</View>
);
return (
<Accordion
ref={(ref) => this.accordionRefs[parseInt(rowID)] = ref} //Keep ref here
header={header}
content={content}
easing='easeOutCubic'
onPress={() => this.onPressSection(parseInt(rowID), this.accordionRefs)} />
);
}
onPressSection(rowID, accordionRefs) {
//Toggle other accordions except of the one clicked
for (let i = 0; i < accordionRefs.length; i++) {
if (i != rowID && accordionRefs[i] != null) {
accordionRefs[i].toggle();
}
}
} Hope it helps |
@fxhereng thanks for the snippet. when using flatlist it won't toggle.
any clue why it won't attach to the ref in order to toggle it? |
It seemed that i was using |
How do i set the first item to be open by default and others to close when another item is selected?
The text was updated successfully, but these errors were encountered: