React-native: TextInput's onLayout not called

Created on 24 Jun 2016  Â·  7Comments  Â·  Source: facebook/react-native

Not sure why the onLayout is not called in TextInput component but called in View component.

  <TextInput
              ref="textInput"
              onLayout={(e) => {
                console.log('--- this is not called?')
              }}
              style={{height: 44, color: 'black', borderColor: 'black', borderWidth: 1, paddingHorizontal: 10, marginHorizontal: 10}}
              placeholder='text here'
              text={'cool'}
              placeholderTextColor={'rgba(0,0,0,.4)'}
              underlineColorAndroid='rgba(0,0,0,0)'
            />

Sample project here

React Native version: 0.28.0
Target: iOS 9.3
Development OS: OS X

Locked

Most helpful comment

@facebook-github-bot open
this is an outstanding bug and it is not fixed on version 0.38.0-rc1
I confirm

All 7 comments

not fix ,I found this bug on a little android‘s device ,example :
Nexus and MEIZU

@facebook-github-bot open
this is an outstanding bug and it is not fixed on version 0.38.0-rc1
I confirm

Not fixed in
react-native-cli: 1.0.0
react-native: 0.37.0

Not working on View
flex: 1,
height: 120
}}>

measureView(event) {
console.log('event peroperties: ', event);

this.setState({svgHeight: event.nativeEvent.layout.height, svgWidth: event.nativeEvent.layout.width});

}

<3 UnicornRainbows

+1
Confirmed that it's broken in RN 0.37.0.
What's the timeline for this fix? This functionality is critical for dynamically sizing content.

This issue has been fixed in this commit -> https://github.com/facebook/react-native/commit/8a073c1d8b89305a9a2561a7c33740919730f408#diff-b48972356bc8dca4a00747d002fc3dd5

Was this page helpful?
0 / 5 - 0 ratings