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

How to use generated variable with alert function?

$
0
0

This is the code that I create for my app in order to provide some error messages:

function createTimer(): void {    if (!timer.start) {    Alert.alert(strings.reminders['date-required'])    return;} else if (!timer.end) {    Alert.alert(strings.reminders['date-required'])    return;}let curTimer = timer;curTimer.task = currentTasksetCreateLoading(true)timerService.create(curTimer).then(() => {    setCreateLoading(false);    Alert.alert(strings.alert.success, '', [        { text: strings.button.ok, onPress: () => closeNewTimerModal() }    ],    { cancelable: false }    )         }).catch(e => {    let message: string;    if(e.code == Error.TIMER_INTERVALS_INTERSECT) {        message = strings['time-tracking']['time-intervals-intersect']    }    else if(e.code == Error.START_DATE_IS_AFTER_END_DATE) {    message = strings['time-tracking']['start-after-end']    }    else if(e.code == Error.END_DATE_IS_AFTER_NOW) {    message = strings['time-tracking']['end-after-now']    }    else if(e.code == Error.TASK_IS_ARCHIVED) {    message = strings['time-tracking']['task-archived']    }    Alert.alert(*)    setCreateLoading(false);})

But I cannot use the message parameter in the alert function.

What should I write where the star is? I think it should be:

Alert.alert(strings.message.something)

but I can't find the something. When I write just Alert.alert(strings.message) the popup opens, but there is no error.


Viewing all articles
Browse latest Browse all 6291

Trending Articles



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