Created
June 7, 2018 22:21
-
-
Save steida/f08dcda8c17528167fb8624df7b1d04b to your computer and use it in GitHub Desktop.
Textarea auto height for server side rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextInput | |
multiline | |
// value={value} | |
defaultValue={value} | |
onChange={this.handleChange} | |
placeholderTextColor={placeholderTextColor} | |
placeholder={intl.formatMessage(messages.placeholder)} | |
ref={this.inputRef} | |
style={[ | |
theme.styles.editorTextInput, | |
theme.typography.fontSizeWithLineHeight(0), | |
]} | |
id={id} | |
/> | |
{/* Set height immediately before the client JavaScript is run. */} | |
{/* This causes Warning: Extra attributes from the server: style */} | |
{/* That's annoying but fine. */} | |
{/* {Platform.OS === 'web' && | |
!('browser' in process) && ( | |
<script | |
// eslint-disable-next-line react/no-danger | |
dangerouslySetInnerHTML={{ | |
__html: ` | |
var el = document.getElementById('${id}'); | |
el.style.height = 0; | |
el.style.height = el.scrollHeight + 'px'; | |
`, | |
}} | |
/> | |
)} */} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment