react-modal icon indicating copy to clipboard operation
react-modal copied to clipboard

Uncaught TypeError: Cannot read property 'Component' of undefined

Open finleyowen opened this issue 2 years ago • 1 comments

When trying to build an app with this dependency, react logs the following error to the console. I've set the appElement to '#root' in my index.js file and tried using ariaHideApp={false}, but neither have solved the error.

Uncaught TypeError: Cannot read property 'Component' of undefined
    at Object.<anonymous> (react-modal.min.js:34)
    at n (react-modal.min.js:1)
    at Object.<anonymous> (react-modal.min.js:13)
    at n (react-modal.min.js:1)
    at Object.<anonymous> (react-modal.min.js:13)
    at n (react-modal.min.js:1)
    at react-modal.min.js:1

finleyowen avatar Aug 26 '21 06:08 finleyowen

@finleyowen Which version are you using?

diasbruno avatar Sep 03 '21 22:09 diasbruno

Same issue i am using version 3.14.3

cbisum avatar Oct 12 '22 23:10 cbisum

If you are using <Modal appElement={node} />, node needs to be a dom node...not a string. Can you check if this is the issue?

diasbruno avatar Oct 12 '22 23:10 diasbruno

I'm facing a similar issue. Here are the attributes I'm passing on to ReactModal.

<ReactModal
        ariaHideApp={false}
        isOpen={showLoginModal}
        onRequestClose={closeModal}
        className="bg-whitish w-[80%] h-[70%] md:w-[50%] md:h-[30%] rounded-md absolute top-[50%] left-[50%] transform -translate-x-1/2 -translate-y-1/2 border border-blackish flex flex-col justify-center items-center"
>

Here is the error I'm getting.

Uncaught TypeError: Cannot read properties of undefined (reading 'Component')
    at Object.<anonymous> (react-modal.min.js:34:9446)
    at n (react-modal.min.js:1:450)
    at Object.<anonymous> (react-modal.min.js:13:4246)
    at n (react-modal.min.js:1:450)
    at Object.<anonymous> (react-modal.min.js:13:3589)
    at n (react-modal.min.js:1:450)
    at react-modal.min.js:1:1250
    at react-modal.min.js:1:1259
    at react-modal.min.js:1:290
    at react-modal.min.js:1:312

Can someone help me out with this?

MadhavKauntia avatar Nov 30 '22 09:11 MadhavKauntia

@MadhavKauntia which version are you using?

diasbruno avatar Nov 30 '22 13:11 diasbruno

@diasbruno 3.15.1

MadhavKauntia avatar Nov 30 '22 13:11 MadhavKauntia

Please, check if this is an incompatibility with newer version of react like 17+.

diasbruno avatar Nov 30 '22 13:11 diasbruno

Uncaught TypeError: Cannot read properties of undefined (reading 'Component') at Object. (react-modal.min.js:34:9446) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:4246) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:3589) at n (react-modal.min.js:1:450) at react-modal.min.js:1:1250 at react-modal.min.js:1:1259 at react-modal.min.js:1:290 at react-modal.min.js:1:312

version is: "react-modal": "^3.16.1",

haratmalli avatar Dec 27 '22 10:12 haratmalli

If you want to make a reproducible example for this...one can create a new react project and add react and react-modal (with some combination of versions).

This should trigger the issue, and, we can finally address it.

diasbruno avatar Dec 27 '22 12:12 diasbruno

As people have found out, if you delete node_modules and reinstall everything, it works. It seems a cache issues. Please, feel free to reopen if that's not your case.

diasbruno avatar Apr 08 '23 19:04 diasbruno

As people have found out, if you delete node_modules and reinstall everything, it works. It seems a cache issues. Please, feel free to reopen if that's not your case.

It still don't work having same issue my react-modal version "react-modal": "^3.16.1" and react version "react": "^18.2.0", error. "react-modal.min.js:34 Uncaught TypeError: Cannot read properties of undefined (reading 'Component') at Object. (react-modal.min.js:34:9446) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:4246) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:3589) at n (react-modal.min.js:1:450) at react-modal.min.js:1:1250 at react-modal.min.js:1:1259 at react-modal.min.js:1:290 at react-modal.min.js:1:312 "

ShivamDev412 avatar Nov 05 '23 02:11 ShivamDev412

react-modal.min.js:34 Uncaught TypeError: Cannot read properties of undefined (reading 'Component') at Object. (react-modal.min.js:34:9446) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:4246) at n (react-modal.min.js:1:450) at Object. (react-modal.min.js:13:3589) at n (react-modal.min.js:1:450) at react-modal.min.js:1:1250 at react-modal.min.js:1:1259 at react-modal.min.js:1:290 at react-modal.min.js:1:312

same issue I am getting. react-modal version "react-modal": "^3.16.1" and react version "react": "^18.2.0",

Screenshot from 2024-04-18 14-43-45

thenarain avatar Apr 18 '24 09:04 thenarain