The Material UI export of 'useInsertionEffect' (imported as 'useInsertionEffect$1') was not located within the 'react' library while utilizing the Appbar component

1: text**

While attempting to implement the Appbar component from Material UI, I encountered an unexpected error.

Answer №1

This issue stemmed from a bug triggered by the direct reference to useInsertionEffect in the specifiers list of the import statement (React.useInsertionEffect instead of React['useInsertion' + 'Effect']). You can find more details about this problem here.

The good news is that this has already been resolved, thanks to the changes made in this update which is included in version

@emotion/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="176572767463572626392f3926">[email protected]</a>
. Simply upgrade to this version and the error should no longer persist.

Answer №3

I encountered a similar issue, although not related to Appbar. My challenge involved creating a custom npm component library using mui v5 components.

ERROR in ./node_modules/comp-lib-mui5-sample/dist/esm/index.js 1293:9-29

The export 'useInsertionEffect' (imported as 'e') was not found in 'react' (possible exports listed)

Attempts to downgrade or upgrade the material and emotion, styled packages did not resolve the problem.

In my rollup.config.js setup:

{
    input: "src/index.ts",
    output: [
        {
            file: pkg.main,
            format: "cjs",
            sourcemap: true,
        },
        {
           file: pkg.module,
           format: "esm",
           sourcemap: true,
         },
    ],
    plugins: [ //plugins here ],
},
{
    input: "dist/esm/types/index.d.ts",
    output: [{file: "dist/index.d.ts", format: "esm"}],
    plugins: [dts()],
    external: [/\.css$/],
},

The esm output is used for building <script type=module> tag in modern browsers.
The cjs format is suitable for Node and other bundlers check rollup output formats here

Solution

To address this issue, I updated the rollup.config.ts to only use cjs:

{
   ...
    output: [
        {
            file: pkg.main,
            format: "cjs",
            sourcemap: true,
        },
        // Removed esm output configuration
    ],
    plugins: [ //plugins here ],
},
{
    input: "dist/types/index.d.ts", // Updated path from dist/esm to dist/types/library.d.ts
    output: [{file: "dist/index.d.ts", format: "esm"}],
    plugins: [dts()],
    external: [/\.css$/],
},

(Tested with versions: "@emotion/react": "^11.8.2", "@emotion/styled": "^11.8.1", "@mui/material": "^5.5.2")

Sample repositories:
component library Access Git repository
consumer of the library View Git repository
(Check README.md for additional details.)

Answer №4

It seems there may be an issue with the most recent release of @emotion/react, version 11.8.0. Since it was only released 3 hours ago, this could explain why it suddenly stopped working.

To address this issue, a temporary solution would be to revert back to the previous version of

@emotion/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f2d3a3e3c2b1f6e6e7168716e">[email protected]</a>
.

Answer №5

The problem extends to other components in the mui library as well. You have the option to revert back to version 11.7.1 of emotion/react until the issue is resolved 🚀

Answer №6

After encountering an issue with my component library, built using @mui and React 18, not being compatible with a consuming application running on v17, I followed the suggestion of @Savchyk Vladyslav to use older versions of @emotion/react and @emotion/styled. Surprisingly, there were no reports of this specific error in the @emotion Github issues, leading me to believe the problem was likely on my end.

By downgrading my library's react version to v17 and updating @emotion/[email protected] and @emotion/[email protected], I successfully resolved the issue and now everything is working smoothly once again :)

Answer №7

Experiencing similar issue here! Reverting back to version 11.7.1 resolved the problem!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

$set { "array.variable.value" :"newvalue"} utilize a different term besides "variable" or implement a new variable

When working with mongoose to store user data, one of the attributes is an array called items. In my additems.js file: const User = require('../models/User'); var array = user.items; array.indexOfObject = function (property, value) { ...

VueJS and Vite: Encountering an unexpected character '�' while attempting to import files that are not JavaScript. Keep in mind that plugins are required for importing such files

I'm puzzled by the error message I'm receiving: [commonjs--resolver] Unexpected character '�' (Note that you need plugins to import files that are not JavaScript) file: /..../..../WebProjects/..../ProjectName/node_modules/fsevents/fse ...

How to send a JavaScript variable to Flask and trigger an AJAX reload action

Introduction: I have explored similar inquiries and attempted to apply relevant code/concepts but without success. -https://stackoverflow.com/questions/43645790/passing-javascript-variable-to-python-flask -https://stackoverflow.com/questions/10313001/is- ...

Switch positions of two objects in JavaScript

Check out the code snippet below: MyObject.prototype.doIt = function() { let a = this.obj1; let b = this.obj2; } I need to find a way to switch the values of this.obj1 and this.obj2, making obj1 take on the value of obj2 and vice versa. Pleas ...

Is there a way to append items to the main level of an array?

I am attempting to populate an array with objects in order to achieve the following structure: myobject1: Object: ItemInside: Object myobject2: Object ItemInside: Object myobject3: Object ItemInside: Object myobject4: Object ItemInside: Ob ...

Using MuiThemeProvider to set a background image for the body

I'm currently working on a react application that utilizes Material UI. I've been able to successfully set the theme's default background color on the body, but now I'm interested in setting a background image instead. Can anyone provid ...

show information retrieved from database according to the drop-down menu selection

Can anyone assist me with this query? I have a drop-down menu that includes "Shop A" and "Shop B". Shop A has a value of 1, and Shop B has a value of 2. When I select Shop A from the dropdown, I want to display the data from the database as a table specifi ...

Expanding list - Using individual toggles to expand and collapse multiple list items

I stumbled upon an interesting jquery script that allows for a collapsible sub menu within a list. After implementing this code: $('.menu-item-has-children').prepend('<a id="fa-menu" href="#"><i class="fa fa-plus"></i>< ...

Button component in React remains visible until interacted with

https://i.stack.imgur.com/gTKzT.png I'm dealing with a sign out component in my app that requires me to click on it specifically to unselect any part of the application. This is implemented using React Material UI. <MenuItem onClick={e => this ...

Is it necessary to clean and reinstall node_modules every time I deploy in a production environment?

We manage over 10 production servers and each time we update our dependencies, performing a clean installation seems more controlled but also slower. The issue is that the devops team is concerned about the time it takes to perform a clean npm install aft ...

Utilize AJAX and jQuery to seamlessly submit a form

I am attempting to use jQuery and AJAX to submit a form in order to add a row to a table called cadreSante (which is in French). The code I am using for this operation is provided below. Can someone please identify any errors in the code and suggest ways t ...

Guide on accessing a local image while setting the background image using JavaScript

I am trying to set a background image from a local source on my computer. Below are two lines of code, one that works and one that does not: (the local one fails) _html.style.backgroundImage = 'url("urlsourceblahblahblah")'; _html.style.backgro ...

A guide on implementing a Material UI table to display one row at a time on each page

I'm currently working on incorporating a Material UI table to showcase content with just one row per page. After successfully loading the page and displaying the first row, I encountered an issue where navigating to subsequent pages does not render a ...

I'm currently working on developing a chat system, but I'm facing an issue where I am unable to send multiple messages consecutively. It seems like there is a problem with the form

My chat application is not allowing me to post multiple messages. Here is the code snippet responsible for sending messages: window.typing = false; var posted = 0; var canPost = 1; var donotrefresh = 0; document.forms['send'].addEventListener(& ...

Creating JEST unit tests for a basic functionality

Here is the React code I have written: getDetails: function () { var apiUrl = ConfigStore.get('api') request .get(apiUrl) .set('X-Auth-Token', AuthStore.jwt) .set('Accept&apo ...

Angular fails to include the values of request headers in its requests

Using Django REST framework for the backend, I am attempting to authenticate requests in Angular by including a token in the request headers. However, Angular does not seem to be sending any header values. Despite trying various methods to add headers to ...

The image source is visible in Vue.js, but unfortunately, my picture is not showing up

Below is the code and script that I have: <template> <div class="tasks_container"> <div class="tasks_content"> <h1>Tasks</h1> <ul class="tasks_list"> ...

Is there a way to trigger a custom event from a Web Component and then intercept it within a React Functional Component for further processing?

I'm facing an issue with dispatching a custom event called "select-date" from a custom web component date picker to a React functional component. Despite testing, the event doesn't seem to be reaching the intended component as expected. Below is ...

The error message "Type 'string | number' is not assignable to type 'number'" indicates a type mismatch in the code, where a value can be either

I encountered an error code while working with AngularJS to create a countdown timer. Can someone please assist me? //Rounding the remainders obtained above to the nearest whole number intervalinsecond = (intervalinsecond < 10) ? "0" + intervalinseco ...

Transferring information using express

Currently, my Express server is up and running and it's set to send an HTML file from the public folder of my project. The issue arises when I try to initiate a request from a client script linked in this HTML file to send data back to the server. Des ...