The difference you're experiencing is actually a discrepancy between React Native Web, which the official React Native documentation uses in its examples, and React Native.
Given the fact that React Native Web does not directly rely on React Native as a dependency, this inconsistency is most likely due to a different implementation of the <ScrollView>
component and how the styling prop is handled and/or propagated.
In general, I wouldn't take for granted the examples provided in the official docs if they also have a device to show the results, because most likely those examples are tailored to work on React Native Web which may or may not (like in this case) behave like React Native.
Details
React Native's <ScrollView>
actually wraps the child views into a <ScrollContentContainerViewClass>
, and for this reason there needs to be a differentiation between the styling that goes to the scroll view itself (usual style
prop) and the styling for this wrapper (the contentContainerStyle
mentioned in @yangguang1029's answer:
// in render function of ScrollView class.
const contentContainer = (
<ScrollContentContainerViewClass
style={contentContainerStyle}> // styling for inner container view.
{children}
</ScrollContentContainerViewClass>
);
// other operations...
return (
<ScrollViewClass {...props} ref={this._setScrollViewRef}> // here the "style" prop is propagated.
{contentContainer}
</ScrollViewClass>
);
Source: React Native ScrollView source on GitHub