Skip to content

Commit

Permalink
Fix compilation error on React < 18
Browse files Browse the repository at this point in the history
The error is "Attempted import error: 'useInsertionEffect' is not exported from 'react' (imported as 'React')."
  • Loading branch information
alex-pex authored and molefrog committed Apr 8, 2024
1 parent 1d577e1 commit c79d1f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/wouter/src/react-deps.js
@@ -1,13 +1,15 @@
import * as React from "react";

// React.useInsertionEffect is not available in React <18
const {
useEffect,
useLayoutEffect,
useRef,
useInsertionEffect: useBuiltinInsertionEffect,
} = React;

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

export {
useRef,
useState,
Expand Down

0 comments on commit c79d1f4

Please sign in to comment.