Skip to content
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

fix: Add sections to onChange props #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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