Open andreaslindahl opened 8 years ago
Would love to know how to do this as well
It would really help me as well if we could have a props returning if the accordion is opened or closed.
I'll submit a PR shortly to have a prop for the opened and closed header ;)
@tsyirvo Did you ever get around to submitting a PR for this? Could use this feature as well.
Could there be a way to access the is_visible
variable to determine being opened or closed?
@digitaldavenyc I didn't submit my PR yet :/
In the meantime, you can change {this.props.header}
on line 106 by this.state.is_visible ? this.props.headerOpened : this.props.headerClosed
.
It will allow you to have two props for the header, one when closed and one when open ;)
@tsyirvo I'm not sure what you mean by that method? Can u elaborate on the implementation.
btw. sorry for super delayed response
Change line 106 to {this.props.header({ isOpen: this.state.is_visible })}
and then you can use your component like
<Accordion
header={({isOpen}) => <View><Text>{isOpen}</Text></View>}
content={<View><Text>Hello World!</Text></View>}
/>
Is is possible to set different styles on the header, depending on whether the accordion is expanded or not?
Also, it is possible to only allow one accordion to be expanded at a time?