I have array in my state I set my state default value to an empty array []. After an API request loads I need to use loader until data is ready. So U use condition like:
(if array length === 0 loader will show otherwise data will show)
but when the API returns empty data I want to show no data available.
What is best way to do that?
My code is below - how can I check the condition if the API returns an empty result?
this.state.offer.length == 0 ? <Loader /> : <OfferList />
if responseFromAPI.length==0 this.setState({emptyAPIResponse: true}), then use that for conditional renderingrenderfunction?