Skip to content

Commit

Permalink
fix: Add sections to onChange props
Browse files Browse the repository at this point in the history
  • Loading branch information
nitaking committed Nov 11, 2018
1 parent a06a3cc commit 2fd64a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -53,7 +53,7 @@ export default class Accordion extends Component {
updatedSections = [section];
}

onChange && onChange(updatedSections);
onChange && onChange(updatedSections, sections);
}
}

Expand Down Expand Up @@ -102,7 +102,7 @@ export default class Accordion extends Component {
{expandFromBottom && renderCollapsible(section, key)}

<Touchable
onPress={() => this._toggleSection(key)}
onPress={() => this._toggleSection(key, sections)}
underlayColor={underlayColor}
{...touchableProps}
>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down

0 comments on commit 2fd64a8

Please sign in to comment.