Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/core/src/hooks/usePrevious/usePrevious.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const strictEquals = <T>(prev: T, next: T) => prev === next;
* const previousCount = usePrevious(count);
*/
export function usePrevious<T>(state: T, compare: (prev: T, next: T) => boolean = strictEquals): T {
// Without `'use no memo'`, React Compiler throws when `panicThreshold` is not `'none'`
// because this hook intentionally violates React's refs rules.
Comment thread
lumirlumir marked this conversation as resolved.
Outdated
'use no memo';

const prevRef = useRef<T>(state);
const currentRef = useRef<T>(state);
const isFirstRender = useRef<boolean>(true);
Expand Down
Loading