1.0.5 • Published 11 months ago

rn-use-background-timer v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Intro

Motivation

Installation

npm install @react-native-async-storage/async-storage

or

yarn add @react-native-async-storage/async-storage

then

npm install rn-use-background-timer

or

yarn add rn-use-background-timer

Usage

const App = () => {
  const { duration } = useBackgroundTimer();
  // or
  const { duration } = useBackgroundTimer({
    keepPreviousTime: true,
    onError: (error) => console.error(error),
    onBackground: () => console.log("App went to background"),
    onActive: () => console.log("App is now active"),
  });

  return (
    <View>
      <Text>App has been in background for {duration} seconds</Text>
    </View>
  );
};

API