useToken 'breakpoints' not returning values
See original GitHub issueDescription
When I use ‘breakpoints’ in useToken, I expect it to return a width value
Link to Reproduction
https://codesandbox.io/s/flamboyant-poincare-19xm1
Steps to reproduce
const [sm, lg] = useToken("breakpoints", ["sm", "lg"]);
const [red500] = useToken("colors", ["red.500"]);
console.log({ sm, lg, red500 });
Chakra UI Version
1.6.12
Browser
Chrome Version 95.0.4638.69 (Official Build) (x86_64)
Operating System
- macOS
- Windows
- Linux
Additional Information
Looks like this broke in this release #4867 (system@1.7.5), because its still working in #4799 (system@1.7.4)
Looking a little deeper, it looks like its caused by this change because breakpoints
is not a part of __cssMap
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (3 by maintainers)
Top Results From Across the Web
useBreakpointValue - Chakra UI
useBreakpointValue is a custom hook which returns the value for the current breakpoint from the provided responsive values object.
Read more >Breakpoints not getting hit while debugging in VS10
When I put a breakpoint in the setter and I change the value of Value from the control the breakpoint is not getting...
Read more >Breakpoints - NativeBase
useBreakpointValue is a custom hook which returns the value for the current breakpoint from the provided responsive values object.
Read more >Troubleshoot Breakpoints in the Visual Studio Debugger
"No Symbols have been loaded for this document". Go to the Modules window (Debug > Windows > Modules) and check whether your module...
Read more >Debugger steps not working in C: hovering over values do not ...
Debugger steps not working in C: hovering over values do not return values, ... ability to retrieve variable values (or execute watches) in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I understand what is causing the issue, I identified that myself in my initial comment.
The
useToken
hook as defined isThis is no longer true and causes unexpected behavior. There is no mention of a
token
s relationship with CSS variables.It’s also an undocumented breaking change for anyone using
breakpoints
withuseToken
, which doesn’t throw an error.Your sandbox is not going to work as you have the
useToken
calls before theChakraProvider
is invoked. The theme is not available at the time you’re making the call so it always returns the default value which in this case the values you requested. This is how the app should be writtenIt will produce the output
The
breakPoints
are not in the __cssMap. I think this is because they are used by media queries so they don’t need to be css variables.