i am using react-native-snap-carousel for my first react-native app.
I have read docs but i see it use static data. But i want to get data form server with API, how can i do it?
Thank you for helping.
You can fetch data from the server and pass it like so:
class MyCoponent extends React.Component{
state = { data: null }
fetchData = () => {
// const result = fetch from api ...
this.setState(() => ({ data: result }))
}
render(){
const { data } = this.state
if(!data){
return <Text>No data</Text>
}
return(
<Carousel data={data}/>
)
}
}