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

Error appears when using Typescript with Alert component in React Native project

$
0
0

I am getting an type error using typescript in my React Project. I am using the alert component and rendering my buttons conditionally.

const buttons = () => {    if (item.type === 'volume') {      // volume: no need to check anything else. overwrite rows and assign volume      return [        {          text: 'Cancel',          onPress: () => console.log('saving cancelled'),          style: 'cancel',        },        {          text: 'Overwrite',          onPress: () => assignToVolume(),        },      ];    } else if (isAssigned === 'volume'&& item.type) {      // delete volume and assign the new item      return [        {          text: 'Cancel',          onPress: () => console.log('saving cancelled'),          style: 'cancel',        },        {          text: 'Overwrite',          onPress: () => owVolumeAssignNewItem(),        },      ];    }}Alert.alert('Midi Mapping Alert', message(), buttons());

enter image description here

I have tried adding the following to my button function which remove the warning but I am not sure what impact it will have

const buttons = (): any =>{{

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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