You must save the content using the details. Suppose there are two files, index.ios.js and test.js
index.ios.js :
'use strict'; var React = require('react-native'); var Test = require('./test'); var { AppRegistry, StyleSheet, Text, TouchableHighlight, View, } = React; class PNTest extends React.Component{ constructor(props){ super(props) } render(){ var content = [<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>,<Text style={styles.welcome}>Text 1</Text>, <Text style={styles.welcome}>Text 2</Text>]; return( <Test content={content}/> ); } } var styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, buttonContainer: { backgroundColor: 'blue', padding: 10, margin: 10, }, button: { textAlign: 'center', color: 'white', fontSize: 20, }, }); AppRegistry.registerComponent('PNTest', () => PNTest);
test.js :
'use strict'; var React = require('react-native'); var { StyleSheet, Text, TouchableHighlight, View, ScrollView } = React; class Test extends React.Component{ constructor(props){ super(props) var _content = (<ScrollView automaticallyAdjustContentInsets={false} horizontal={false} style={styles.scrollView}> <View style={styles.container}> {this.props.content} </View> </ScrollView>); this.state = { content: _content } } render(){ return( this.state.content ); } } var styles = StyleSheet.create({ container: { margin: 30, flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10 }, buttonContainer: { backgroundColor: 'blue', padding: 10, margin: 10, }, button: { textAlign: 'center', color: 'white', fontSize: 20, }, scrollView: { backgroundColor: '#6A85B1', height: 300, }, }); module.exports = Test;
screenshots:
top:

bottom:
