Skip to content

Commit

Permalink
Update react-deps.js
Browse files Browse the repository at this point in the history
fix RollupError: [commonjs--resolver] node_modules/wouter/esm/react-deps.js (8:2): Identifier "useRef" has already been declared
  • Loading branch information
huazhuangnan committed Apr 9, 2024
1 parent cf9ba61 commit 3952486
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/wouter/src/react-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as React from "react";
const {
useEffect,
useLayoutEffect,
useRef,
} = React;

// React.useInsertionEffect is not available in React <18
Expand Down Expand Up @@ -58,7 +57,7 @@ export const useInsertionEffect =
// .current at the right timing."
// So we will have to make do with this "close enough" approach for now.
export const useEvent = (fn) => {
const ref = useRef([fn, (...args) => ref[0](...args)]).current;
const ref = React.useRef([fn, (...args) => ref[0](...args)]).current;
// Per Dan Abramov: useInsertionEffect executes marginally closer to the
// correct timing for ref synchronization than useLayoutEffect on React 18.
// See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
Expand Down

0 comments on commit 3952486

Please sign in to comment.