diff --git a/Accordion.js b/Accordion.js index 761dc9e..766f2a1 100644 --- a/Accordion.js +++ b/Accordion.js @@ -39,7 +39,7 @@ export default class Accordion extends Component { sectionContainerStyle: {}, }; - _toggleSection(section) { + _toggleSection(section, sections) { if (!this.props.disabled) { const { activeSections, expandMultiple, onChange } = this.props; @@ -53,7 +53,7 @@ export default class Accordion extends Component { updatedSections = [section]; } - onChange && onChange(updatedSections); + onChange && onChange(updatedSections, sections); } } @@ -102,7 +102,7 @@ export default class Accordion extends Component { {expandFromBottom && renderCollapsible(section, key)} this._toggleSection(key)} + onPress={() => this._toggleSection(key, sections)} underlayColor={underlayColor} {...touchableProps} > diff --git a/README.md b/README.md index 93c6bb1..aba6d66 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ import Accordion from 'react-native-collapsible/Accordion'; | **`renderHeader(content, index, isActive, sections)`** | A function that should return a renderable representing the header | | **`renderContent(content, index, isActive, sections)`** | A function that should return a renderable representing the content | | **`renderSectionTitle(content, index, isActive)`** | A function that should return a renderable representing the title of the section outside the touchable element | -| **`onChange(indexes)`** | A function that is called when the currently active section(s) are updated. | +| **`onChange(indexes, sections)`** | A function that is called when the currently active section(s) are updated. | | **`activeSections`** | Control which indices in the `sections` array are currently open. If empty, closes all sections. | | **`underlayColor`** | The color of the underlay that will show through when tapping on headers. Defaults to black. | | **`touchableComponent`** | The touchable component used in the Accordion. Defaults to `TouchableHighlight` |