Skip to content

Commit

Permalink
Merge pull request #4 from sehranhas/reset-height
Browse files Browse the repository at this point in the history
reset content height every time component is visited
  • Loading branch information
sehranhas authored Jun 6, 2018
2 parents bb350b4 + b2d21a2 commit 63338fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Accordion extends Component {
constructor(props) {
super(props);
this.state = {
expanded: false,
expanded: props.expanded,
height: new Animated.Value(0),
content_height: 0
};
Expand Down Expand Up @@ -86,6 +86,11 @@ class Accordion extends Component {
setTimeout(this._getContentHeight);
}

componentWillReceiveProps() {
this.state.height.setValue(0);
this.setState({expanded: this.props.expanded});
}

render() {
return (
/*jshint ignore:start */
Expand All @@ -110,7 +115,7 @@ class Accordion extends Component {
}}
>
<View ref="AccordionContent">
{(Platform.OS === 'ios' || this.state.expanded) ? this.props.content : null}
{this.props.content}
</View>
</Animated.View>
</View>
Expand Down

0 comments on commit 63338fe

Please sign in to comment.