this.state.wrapperHeight gets updated whenever either of those inputs changes
Also, I've added a callback this.props.onHeightChange that gets called when this.state.wrapperHeight changes
Relatedly, this PR changes the logic for when scrollToBottom gets triggered. In this PR it gets called whenever this.contentHeight increases. In the current version, it gets triggered whenever onLayoutLastTag gets called and the max this.props.numberOfLines has already been reached. I found the current behavior buggy, and it doesn't always get triggered when you would expect it to.
Currently,
wrapperHeight
is determined in the following way:this.state.lines
starts out at 1wrapperHeight = (this.state.lines - 1) * 40 + 36
this.state.lines
never goes abovethis.props.numberOfLines
this.state.lines
gets incremented wheneveronLayoutLastTag
is called withspaceLeft < 100
My proposal:
this.state.wrapperHeight = Math.min(this.props.maxHeight, this.contentHeight)
this.state.wrapperHeight
gets updated whenever either of those inputs changesthis.props.onHeightChange
that gets called whenthis.state.wrapperHeight
changesRelatedly, this PR changes the logic for when
scrollToBottom
gets triggered. In this PR it gets called wheneverthis.contentHeight
increases. In the current version, it gets triggered wheneveronLayoutLastTag
gets called and the maxthis.props.numberOfLines
has already been reached. I found the current behavior buggy, and it doesn't always get triggered when you would expect it to.