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

React native - state does not get updated inside renderItem function in SwipListView

$
0
0

As explained stateItem throws an error, and when I console.log stateItem after I set the state it comes out as null. Can someone please tell me why this happens? The code is below:

const [stateItem, setStateItem] = useState(null);<SwipeListView              data={list}              listKey={'list'}              keyExtractor={list=> list.id}              closeOnScroll={true}              closeOnRowBeginSwipe={true}              renderItem={({ item }) => (<View><TouchableWithoutFeedback                    onPress={() => {                    setStateItem(item);><View><Text>{item.category}</Text></View></TouchableWithoutFeedback></View>              )}            />

Viewing all articles
Browse latest Browse all 6295

Trending Articles



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