How to manually trigger a resize?
karlingen opened this issue · comments
Karl Metum commented
We're using custom fonts in our app that might take a bit for them to load. When they've successfully been rendered, react-textarea-autosize
does not automatically resize.
In version 7, we could simply call _resizeComponent()
to force an update. This is no longer possible in version 8.
// Version 8.3.2
import TextareaAutosize from 'react-textarea-autosize';
import React = require('react');
class NoteComponent extends React.Component {
private _contentTextArea: HTMLTextAreaElement;
constructor(props) {
super(props);
}
componentDidMount() {
// Wait for the fonts to finish rendering and then trigger a resize.
setTimeout(() => {
this._contentTextArea._resizeComponent(); // Not working.
}, 500);
}
render () {
return <TextareaAutosize ref={n => this._contentTextArea = n} />
}
}
What's the official way of triggering an update / resize?
Mateusz Burzyński commented
You could trigger a rerender with a new key
Karl Metum commented
Ahh, of course! Thank you!
Konstantin Krivlenia commented
But it is not the same. If we change key focus will be lost.