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

How can I render Alarm item in FlatList with typescript?

$
0
0

I'm making a FlatList rendering Alarm items. (react-native-simple-alarm)

the tsx file where my FlatList is

const [alarms, setAlarms] = useState<AlarmType[]>([]);...const renderItem: ListRenderItem<AlarmType> = ({item}) => {    return <ListItem props={item} />; // i have an error here on props  };...<FlatList            ref={flatListRef}            scrollEnabled={scrollEnabled}            data={alarms}            renderItem={renderItem}              keyExtractor={item => item.oid} //error here on keyExtractor          />

the Alarm list items that FlatList renders

import {Alarm as AlarmType} from 'react-native-simple-alarm/dist/Types';const ListItem = (props: AlarmType) => {  const deleteItem = async (oid: string | number) => {    try {      await deleteAlarmById(oid);...

in ListItem, I also get errors saying that oid cannot be undefined.Not sure it's because of this problem, but the time properties of alarm instances that i made in application get messed up, as I make another instances

How can I use Alarm type perfectly?? please help me


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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