Skip to content

Commit

Permalink
fix: properly name useMountEffect and useUnmountEffect parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi committed Apr 16, 2021
1 parent 4156209 commit 5218bfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/useMountEffect.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useEffect } from 'react';
import { EffectCallback, useEffect } from 'react';

/**
* Run effect only when component is first mounted.
*
* @param fn effector to run on nmount
* @param effect effector to run on nmount
*/
export function useMountEffect(fn: () => void): void {
export function useMountEffect(effect: EffectCallback): void {
useEffect(() => {
fn();
effect();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}
8 changes: 4 additions & 4 deletions src/useUnmountEffect.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect } from 'react';
import { EffectCallback, useEffect } from 'react';

/**
* Run effect only when component is unmounted.
*
* @param fn effector to run on unmount
* @param effect effector to run on unmount
*/
export function useUnmountEffect(fn: () => void): void {
export function useUnmountEffect(effect: EffectCallback): void {
useEffect(
() => () => {
fn();
effect();
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
Expand Down

0 comments on commit 5218bfc

Please sign in to comment.