I am developing app with RN 0.59.8. I am trying to create scrollable view horizontally with ScrollView. Here is basis of my code (sorry I couldn't share more detail):
import React, { Component, Fragment } from 'react';
import {
ScrollView,
} from 'react-native';
import {
Container,
Content,
} from 'native-base';
import { Grid, Row } from 'react-native-easy-grid';
import ChildComponent from './ChildComponent';
class MyComponent extends Component {
render() {
const {
data,
} = this.props;
return (
<Container>
<Content>
<Grid>
<Row>
<ScrollView
horizontal
contentContainerStyle={{
flex: 1, flexGrow: 1, flexDirection: 'row',
}}
>
{
data.map((item, index) => {
const order = index;
return (
<Fragment key={order}>
{
<ChildComponent />
}
</Fragment>
);
})
}
</ScrollView>
</Row>
</Grid>
</Content>
</Container>
);
}
}
export default MyComponent;
Current behavior:
- if
contentContainerStyle={{ flex: 1, flexGrow: 1, flexDirection: 'row' }}, the second data not appear - if
contentContainerStyle={{ flex: 1, flexGrow: 1, flexDirection: 'column' }}, the second data appear vertically - if
contentContainerStyle={{ flexDirection: 'row' }}, the second data not appear and the content is wider than the screen width
My objection is:
- I want to make it scrollable horizontally
- Each data will fit the screen width
Any help would be very helpful. Thank you!!!
