I started learning React Native. As far as I see, there is both an "overflow:scroll" style property and a ScrollView. Does using "overflow:scroll" in a View make it a ScrollView in React Native?
In the ScrollView, we can scroll the components in both direction vertically and horizontally. By default, the ScrollView container scrolls its components and views in vertical. To scroll its components in horizontal, it uses the props horizontal: true (default, horizontal: false).
You can use ScrollView for this case. Just put your text inside it and set height to scroll view. Show activity on this post.
zIndex is the Expo and React Native analog of CSS's z-index property which lets the developer control the order in which components are displayed over one another.
if you want overflow: scroll in react native then you have to use these two props
like this
import React, { Component } from "react";
import { ScrollView, View } from "react-native";
const { height } = Dimensions.get("window");
export class index extends Component {
state = {
screenHeight: 0,
};
onContentSizeChange = (contentWidth, contentHeight) => {
this.setState({ screenHeight: contentHeight });
};
render() {
const scrollEnabled = this.state.screenHeight > height;
return (
<ScrollView
style={{ flex: 1 }}
contentContainerStyle={styles.scrollview}
scrollEnabled={scrollEnabled}
onContentSizeChange={this.onContentSizeChange}
>
<View style={styles.content}></View>
</ScrollView>
);
}
}
export default index;
View does not have an overflow: scroll
property, the docs only show:
overflow ReactPropTypes.oneOf(['visible', 'hidden'])
The only ways to make a scrollable View are to either use ScrollView or ListView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With