Skip to content

Commit

Permalink
chore(2.0.3): 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chooin committed Feb 20, 2022
1 parent 747b4d9 commit fbfac78
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-lifecycle",
"version": "2.0.2",
"version": "2.0.3",
"description": "React Native Lifecycle",
"main": "dist/index.js",
"repository": "[email protected]:chooin/react-native-lifecycle.git",
Expand All @@ -20,7 +20,7 @@
},
"scripts": {
"prepare": "husky install",
"build": "tsc"
"build": "tsc && api-extractor run"
},
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion src/useAppActive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react';
import { AppState, AppStateStatus } from 'react-native';

/**
* App 从后台变为前台时执行
* Called when the application from background to foreground
* @public
*/
export function useAppActive(fn: () => void): void {
Expand Down
2 changes: 1 addition & 1 deletion src/useAppInactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react';
import { AppState, AppStateStatus, Platform } from 'react-native';

/**
* App 从前台变为后台时执行
* Called when the application from foreground to background
* @public
*/
export function useAppInactive(fn: () => void): void {
Expand Down
3 changes: 1 addition & 2 deletions src/useHide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {
import { useNavigation } from '@react-navigation/native';

/**
* 页面从前台变为后台时执行
* Called when the page is hidden or in the application from foreground to background
* @public
*/
export function useHide(fn: () => void): void {
const navigation = useNavigation();
const AppStateRef = useRef<EmitterSubscription | null>(null);

// ? App 从前台变为后台时执行
const onChange = (state: AppStateStatus) => {
if (
state ===
Expand Down
2 changes: 1 addition & 1 deletion src/useLoad.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';

/**
* 页面创建时执行
* Called when the page load
* @public
*/
export function useLoad(fn: () => void): void {
Expand Down
2 changes: 1 addition & 1 deletion src/useResize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react';
import { Dimensions } from 'react-native';

/**
* 页面尺寸变化时执行
* Called after the page window resize
* @public
*/
export function useResize(fn: () => void): void {
Expand Down
3 changes: 1 addition & 2 deletions src/useShow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import {
import { useNavigation } from '@react-navigation/native';

/**
* 页面出现在前台时执行
* Called when the page is displayed or in the application from background to foreground
* @public
*/
export function useShow(fn: () => void): void {
const navigation = useNavigation();
const AppStateRef = useRef<EmitterSubscription | null>(null);
const isAppStateChangeRef = useRef(false);

// ? App 从后台变为前台时执行
const onChange = (state: AppStateStatus) => {
if (isAppStateChangeRef.current) {
if (state === 'active') {
Expand Down
2 changes: 1 addition & 1 deletion src/useUnload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';

/**
* 页面销毁时执行
* Called when the page is unloaded
* @public
*/
export function useUnload(fn: () => void): void {
Expand Down

0 comments on commit fbfac78

Please sign in to comment.