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.

useBreakpointValue - Cannot convert undefined or null to object

See original GitHub issue

🐛 Bug report

Just updated from "@chakra-ui/core": "^1.0.0-rc.8" to "@chakra-ui/react": "^1.1.4", and now I’m getting this error:

TypeError: Cannot convert undefined or null to object

on this line: const size = useBreakpointValue({ base: 'full', sm: 'xs' })

Which used to work just fine.

image

💥 Steps to reproduce

Link to codesandbox

🧐 Expected behavior

Don’t throw an error and worked as it was working on previous versions?

Issue Analytics

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

github_iconTop GitHub Comments

8reactions
with-heartcommented, Jan 11, 2021

You’re using useBreakpointValue outside of ChakraProvider, so it doesn’t have access to the theme in order to read the breakpoints.

4reactions
wyrmmmcommented, May 19, 2021

I’m facing this problem also. Using "@chakra-ui/react": "^1.6.2".

On initial page load, useBreakpointValue returns undefined. After that, it returns the correct value.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot convert undefined or null to object - Stack Overflow
Generic answer. This error is caused when you call a function that expects an Object as its argument, but pass undefined or null...
Read more >
cannot convert undefined or null to object react - You.com
Type Error: Cannot convert undefined or null to object​​ The issue is that you can't create an array of keys from an undefined...
Read more >
Cannot convert undefined or null to object : r/learnjavascript
For some reason, when I fetch data and console.log it, it displays the data. But when I set it to a state, it...
Read more >
@chakra-ui/react Switch TypeScript Examples
underlyingToken); const supplyAPY = convertMantissaToAPY(asset. ... Code: " + response, description: "You cannot disable this asset as collateral as you ...
Read more >
Cannot convert undefined or null to object - JavaScript
JavaScript : How to resolve TypeError: Cannot convert undefined or null to object [ Gift : Animated Search Engine ...
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