Skip to main content

useTimedAction

This hook allows to execute (or not) a callback respecting the user "Time to take action" Time or the screen reader.

Usage

import {useTimedAction} from 'react-native-ama';

const {onTimeout} = useTimedAction();

onTimeout

This function is similar to the JavaScript setTimeout one. The main difference is that it might execute or not the given callback.

On Android, if the user specified a custom value for the Time to take action, this is used instead of the one provided.

While, on iOS, the callback is never executed if the screen reader is on.

Syntax

async onTimeout(callback, timeInMilliseconds)

Example

await onTimeout(() => {
setShowContent(false);
}, 30 * 1000);