TypeError: Cannot read property 'Tag' of undefined #108
-
I added your package to use multi select and my tests broke. Do you have any idea what it might be? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
I need a little more info to have any idea whats going on with this?
|
Beta Was this translation helpful? Give feedback.
-
I'm also getting this error all of a sudden. The component was working fine and now it's not. |
Beta Was this translation helpful? Give feedback.
-
@Keeeeith are you on the latest version of the component? |
Beta Was this translation helpful? Give feedback.
-
Yeah I think it was related to a dependency duplicate/conflict of the Emotion package. While searching I came across others who'd had a similar dependency problem with react-select. When I got that straightened out the error went away. |
Beta Was this translation helpful? Give feedback.
-
@Keeeeith What did you end up having to do to get the conflict sorted out? |
Beta Was this translation helpful? Give feedback.
-
@csandman The error started before my planned changes, but the changes were a pretty significant overhaul of my project so I don't think details will be much help to anyone else. I had a locally imported and symlinked component library that had Chakra UI as a dependency and I think that was part of the Emotion conflict. Looking closer at my own screenshot right now, maybe my chakraTheme.components object was over-riding this package? I also import theme as chakraTheme and have a import { extendTheme, theme as chakraTheme } from "@chakra-ui/react" |
Beta Was this translation helpful? Give feedback.
-
I'm seeing the same {
"@chakra-ui/react": "^1.7.2",
"react-select": "^4.3.1",
"chakra-react-select": "^1.3.4",
"@emotion/react": "^11.7.0",
} and testing with jest + react testing library. EDIT: To fix this I simply had to wrap my tests with I've got a bunch of tests that run fine without being wrapped in |
Beta Was this translation helpful? Give feedback.
-
@magnuslinden That would probably be the standard answer to this question. This component accesses the global Chakra theme for styles in case a user has overridden any of them. I tried to avoid hardcoding any chakra styles where I could to keep things looking consistent. @dribeirodev Does wrapping your tests in a |
Beta Was this translation helpful? Give feedback.
I'm seeing the same
TypeError: Cannot read properties of undefined (reading 'Tag')
error in my tests, running:and testing with jest + react testing library.
EDIT:
To fix this I simply had to wrap my tests with
<ChakraProvider>[...]</ChakraProvider>
. Figured that out by looking at Chakra's own testing utilities found here: https://github.com/chakra-ui/chakra-ui/blob/main/tooling/test-utils/src/test-utils.tsxI've got a bunch of tests that run fine without being wrapped in
<ChakraProvider>
, which threw me off when tests that had this package included failed, but…