Skip to content

Commit

Permalink
fix: use Object.is to compare whether the two values have changed (#1593
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hchlq authored May 9, 2022
1 parent d251ba6 commit d5a4509
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hooks/src/usePrevious/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRef } from 'react';

export type ShouldUpdateFunc<T> = (prev: T | undefined, next: T) => boolean;

const defaultShouldUpdate = <T>(a?: T, b?: T) => a !== b;
const defaultShouldUpdate = <T>(a?: T, b?: T) => !Object.is(a, b);

function usePrevious<T>(
state: T,
Expand Down

0 comments on commit d5a4509

Please sign in to comment.