diff --git a/index.js b/index.js index ad7a9cd..474a7f3 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,10 @@ import { } from 'react-native'; export default class ReadMore extends React.Component { + static defaultProps = { + expanded: false + } + state = { measured: false, shouldShowReadMore: false, @@ -26,6 +30,10 @@ export default class ReadMore extends React.Component { if (fullHeight > limitedHeight) { this.setState({shouldShowReadMore: true}, () => { this.props.onReady && this.props.onReady(); + + if (this.props.expanded) { + this._handlePressReadMore() + } }); } } @@ -44,7 +52,8 @@ export default class ReadMore extends React.Component { { this._text = text; }}> + ref={text => { this._text = text; }} + style={{opacity: this.state.measured ? 1 : 0}}> {this.props.children}