React Native TextInput auto grow when multilne

前端 未结 3 1126
后悔当初
后悔当初 2020-12-19 03:45

I want to create a TextInput which can grow automatically when it has multilines.

 

        
3条回答
  •  独厮守ぢ
    2020-12-19 04:04

    With React Hooks

    Just to add to Shivam's answer, here is the version with hooks:

    import React, { useState } from 'react'
    
    export default function MyTextInput(props) {
        const [height, setHeight] = useState(42)
        return  setHeight(e.nativeEvent.contentSize.height)} />
    }
    

提交回复
热议问题