Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tweak imports #441

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions packages/wouter/src/react-deps.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import * as React from "react";

const {
useEffect,
useLayoutEffect,
useRef,
} = React;

// React.useInsertionEffect is not available in React <18
// This hack fixes a transpilation issue on some apps
const useBuiltinInsertionEffect = React['useInsertion' + 'Effect'];
const useBuiltinInsertionEffect = React["useInsertion" + "Effect"];

export {
useRef,
Expand Down Expand Up @@ -43,8 +37,8 @@ const canUseDOM = !!(
// To get around it, we can conditionally useEffect on the server (no-op) and
// useLayoutEffect in the browser."
export const useIsomorphicLayoutEffect = canUseDOM
? useLayoutEffect
: useEffect;
? React.useLayoutEffect
: React.useEffect;

// useInsertionEffect is already a noop on the server.
// See: https://github.com/facebook/react/blob/main/packages/react-server/src/ReactFizzHooks.js
Expand All @@ -58,7 +52,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