//import liraries import React, { Component } from 'react' import { TouchableOpacity } from 'react-native' // create a component class CarouselItem extends Component { constructor(props) { super(props) this.state = { width: props.width, } } getwidth(e) { this.setState({ width: e.width, }) } render() { return ( { this.props.imgTouch(this.props.index) }} onLayout={e => this.getwidth(e.nativeEvent.layout)} > {this.props.item} ) } } //make this component available to the app export default CarouselItem