-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
-
react-native -v
:
react-native-cli: 2.0.1
react-native: 0.45.1 -
node -v
:
v8.1.2 -
npm -v
:
5.0.3 -
yarn --version
(if you use Yarn):
not use yarn
Then, specify:
-
Target Platform (e.g. iOS, Android):
iOS and Android -
Development Operating System (e.g. macOS Sierra, Windows 10):
macOS Sierra -
Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
Xcode 8.3.3
Android Studio 2.3
iOS version 10.3.2
Android SDK version 23
Steps to Reproduce
- Create a new RN project with react-native init APP
- Replace the initial codes withe the codes below (The codes might seem unnecessarily complicated, but it was extracted and simplified from a real project as a minimal version to reproduce the issue.):
import React, { Component } from 'react';
import {
AppRegistry,
Text,
View,
ScrollView
} from 'react-native';
export default class App extends Component {
render() {
return (
<View style={{flex:1, paddingTop:50}}>
<ScrollView contentContainerStyle={{borderWidth:1, borderColor:'red'}}>
<View style={{flexDirection:'row'}}>
<View style={{alignItems:'flex-start', backgroundColor:'gray', padding:20}}>
<View>
<Text>
{'\n'}
</Text>
</View>
</View>
</View>
<View style={{height:50}} />
<View style={{flexDirection:'row'}}>
<View style={{alignItems:'flex-start', backgroundColor:'gray', padding:20}}>
<View>
<Text>
row 2
</Text>
</View>
</View>
</View>
</ScrollView>
</View>
);
}
}
AppRegistry.registerComponent('App', () => App);
- Run the project on iOS or Android
Expected Behavior
The codes above simply show two rows in a scroll view. In the first row, it shows a Text component with a linefeed '\n', while in the second row, it shows a Text component with a string 'row 2'.
The expected behaviour is shown as the screenshot below:
Where the red border shows the border of the content container of the scroll view.
Actual Behavior
The actual behaviour is shown below in order of iOS and Android:
As you can see, the second row is kicked out of the content container of the scroll view on iOS. On Android, the second row does not even show at all.
Reproducible Demo
I created an expo demo to show the issue. Just scan the QR code and you will see the issue on the first screen.
https://snack.expo.io/By2lZquNZ
Notes
I have some notes here to help relieve the work of debugging:
- Replacing the linefeed '\n' with empty string, the issue remains.
- In the first row, replacing the linefeed '\n' with any other non-empty string will get rid of this issue.
- Removing flexDirection:'row' or alignItems:'flex-start' from the first row will get rid of this issue.