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

Breaking change introduced in 2.10.0 #292

Closed
hudochenkov opened this issue Feb 27, 2023 · 3 comments
Closed

Breaking change introduced in 2.10.0 #292

hudochenkov opened this issue Feb 27, 2023 · 3 comments

Comments

@hudochenkov
Copy link

Version 2.10.0 uses useInsertionEffect, which is not available in React 17. It breaks the build:

ERROR in ./node_modules/wouter/react-deps.js 46:2-27

export 'useInsertionEffect' (imported as 'useBuiltinInsertionEffect') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)

In the error webpack can't find export, which is correct, since React 17 doesn't have this hook.

@cbbfcd
Copy link
Contributor

cbbfcd commented Feb 28, 2023

You can go back to v2.9.x first. maybe should add some description about it in readme

@HansBrende
Copy link
Contributor

I believe this can be fixed simply by changing

import {
  useEffect,
  useLayoutEffect,
  useRef,
  useInsertionEffect as useBuiltinInsertionEffect,
} from "react";

to:

import * as React from "react";
const {useEffect, useLayoutEffect, useRef, useInsertionEffect: useBuiltinInsertionEffect} = React;

The intention was for useInsertionEffect to be undefined on React 17, not throw an error. (And if so, use useLayoutEffect instead).

@molefrog
Copy link
Owner

Thank you for reporting this. Has been fixed in v2.10.1
f9333dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants