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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix export 'useInsertionEffect' (imported as 'React') was not found in 'react' on React < 13 #3148

Open
rusikf opened this issue Jan 12, 2024 · 3 comments

Comments

@rusikf
Copy link

rusikf commented Jan 12, 2024

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch @emotion/use-insertion-effect-with-fallbacks@1.0.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js b/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js
index 1b0e17d..b632900 100644
--- a/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js
+++ b/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
 
 var syncFallback = function syncFallback(create) {
   return create();

This issue body was partially generated by patch-package.

@Andarist
Copy link
Member

I'd love to see a repro case for the problem that you have experienced. It's important to know what exact tools were involved.

@rusikf
Copy link
Author

rusikf commented Jan 15, 2024

Thanks for your response! @Andarist

I have this error during webpack compilation.

ERROR in ./node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js 5:25-52
export 'useInsertionEffect' (imported as 'React') 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)
 @ ./node_modules/react-select/node_modules/@emotion/react/dist/emotion-react.browser.esm.js 5:0-142 192:2-38 215:2-38 305:2-42
 @ ./node_modules/react-select/dist/react-select.esm.js 8:0-47 41:45-58

Source code - /node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js

import * as React from 'react';

var syncFallback = function syncFallback(create) {
  return create();
};

var useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : false;
var useInsertionEffectAlwaysWithSyncFallback = useInsertionEffect || syncFallback;
var useInsertionEffectWithLayoutFallback = useInsertionEffect || React.useLayoutEffect;

export { useInsertionEffectAlwaysWithSyncFallback, useInsertionEffectWithLayoutFallback };

Recap: Code has fallback in declaration of var useInsertionEffect => webpack must not raise an error on import * step, Do you have any ideas?
Thanks! 馃槈

@Andarist
Copy link
Member

I need a full runnable/clonable repro case to debug this.

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

2 participants