diff --git a/example/src/App.tsx b/example/src/App.tsx index 4a399e0..873d4de 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,18 +1,17 @@ import * as React from 'react'; import { StyleSheet, View, Text } from 'react-native'; -import { multiply } from 'react-native-inactive-time'; +import useInactivityListener from 'react-native-inactive-time'; +import CustomText from './CustomText'; export default function App() { - const [result, setResult] = React.useState(); - - React.useEffect(() => { - multiply(3, 7).then(setResult); - }, []); + const { elapsedTime, formattedTime } = useInactivityListener(); return ( - Result: {result} + + Elapsed Time: {elapsedTime} + Formatted Time: {formattedTime} ); } diff --git a/example/src/CustomText.tsx b/example/src/CustomText.tsx new file mode 100644 index 0000000..b35c400 --- /dev/null +++ b/example/src/CustomText.tsx @@ -0,0 +1,22 @@ +import { View, Text } from 'react-native'; +import { useEffect, useState } from 'react'; +import { getElapsedTime, type ITime } from 'react-native-inactive-time'; + +const CustomText = () => { + const [elapsedTime, setElapsedTime] = useState(null); + useEffect(() => { + onMount(); + }, []); + + const onMount = async () => { + const elapsedTime = await getElapsedTime(); + setElapsedTime(elapsedTime); + }; + return ( + + Using UseEffect: {elapsedTime} + + ); +}; + +export default CustomText;