Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React native state is not updating UI elements

$
0
0

im trying to fill up my view with elements. I am trying to use SetEvents to make the UI update, however it is not working.

My getEventsInCity returns standardResponse, .data of this is of type IEvent[]

My state

const [events, setEvents] = useState<IEvent[]>([testEvent,testEvent,testEvent])

My function

async function testBtn() {    setCity("XXXX")    const userInfo: LoginRequest = {        uniqueId: 'XXXXX',        phoneOs: 'XXXX',        gender: 'X',        phoneName: 'XXXX',        lat: XXXX,        lon: XXXX    }    await login(userInfo)    getEventsInCity("XXXX").then((o) =>{        setEvents([...o.data])    }).catch((err) => {        console.log(err)    })}

My HTML (I am using a bottom sheet package)The last EventCell is just for testing that my view is showing

<BottomSheetScrollView                 horizontal={false}                showsHorizontalScrollIndicator={false}                style={styles.eventScrollView}>                {events.map((e, i) => {<EventCell event={e} onClick={(eventClicked)} />                })}<EventCell event={testEvent} onClick={(eventClicked)} /></BottomSheetScrollView>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>