question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot use 'in' operator to search for 'gray' in undefined

See original GitHub issue

I think there is a bug with the chakra typing, can anyone help to resolve this issue? This is what I get when using Chakra in a Create-React-App Typescript.

useVariantColorWarning /node_modules/@chakra-ui/core/dist/es/utils/index.js:113

  110 | var variantColorIsDefined = variantColor != null;
  111 | 
  112 | if (variantColorIsDefined) {
> 113 |   var variantColorExists = variantColor in theme.colors; // If variant color exists in theme object
      | ^  114 | 
  115 |   if (!variantColorExists) {
  116 |     console.warn("You passed an invalid variantColor to the " + label + " Component. Variant color values must be a color key in the theme object that has '100' - '900' color values. Check http://chakra-ui.com/theme#colors to see possible values");

/node_modules/@chakra-ui/core/dist/es/Button/index.js:62

  59 | 
  60 | // Wrong usage of `variantColor` prop is quite common
  61 | // Let's add a warning hook that validates the passed variantColor
> 62 | useVariantColorWarning("Button", variantColor);
     | ^  63 | var buttonStyleProps = useButtonStyle({
  64 |   color: variantColor,
  65 |   variant: variant,

``

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
segunadebayocommented, May 16, 2020

Hi @ivanjeremic,

This error shows up when you don’t wrap your App with ThemeProvider from Chakra.

Here’s what you need to do:

// import the provider
import { ThemeProvider, CSSReset } from '@chakra-ui/core'

// in your index.tsx, add this

<ThemeProvider>
   <CSSReset />
   <App/>
</ThemeProvider>
8reactions
absolutelysimoncommented, Jun 7, 2020

Perhaps the “Getting Started” documentation should specify that < ThemeProvider > must be the outermost component?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: cannot use 'in' operator to search for 'x' in 'y'
The in operator can only be used to check if a property is in an object. You can't search in strings, or in...
Read more >
Uncaught TypeError: Cannot use 'in' operator to search for ...
The in operator only works on objects. You are using it on a string. Make sure your value is an object before you...
Read more >
cannot use 'in' operator to search for vue
The in operator can only be used to check if a property is in an object. You can't search in strings, or in...
Read more >
Cannot use 'in' operator to search for 'default' in undefined
hello, I clone this project in my local, and then i exec npm run dev, but in console errors come, Uncaught TypeError: Cannot...
Read more >
JavaScript TypeError - Cannot use 'in' operator to search for 'X ...
This JavaScript exception Cannot use 'in' operator to search for 'X' in 'Y' occurs if in operator is used to search in strings,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found