-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useToken 'breakpoints' not returning values #5045
Comments
Without knowing a better way to solve this issue it seems like rolling back to before #4842 and finding a better solution makes the most sense because 4842 is a breaking change. Using |
Thinking about this a bit more, I'm wondering if something like stitches provides some guidance here. I'm also thinking that if you avoided dot notation, you could use brackets for explicitly identifying nested parameters. For example:
|
Your sandbox is not going to work as you have the import React from "react";
import ReactDOM from "react-dom";
import { Box, ChakraProvider, useToken, Text } from "@chakra-ui/react";
import { get } from "@chakra-ui/utils"
import { useTheme } from "@emotion/react";
function App() {
const theme = useTheme()
const [sm, lg] = ['sm', 'lg'].map(bkpt => get(theme, `breakpoints.${bkpt}`, bkpt));
const [red500] = useToken("colors", ["red.500"]);
return (
<Box padding={4}>
<Text>{sm}</Text>
<Text>{lg}</Text>
<Text>{red500}</Text>
</Box>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(
<ChakraProvider>
<App />
</ChakraProvider>,
rootElement
); It will produce the output
The |
Ah yes, how foolish of me! That is now updated. |
Sorry, why is this closed? The updated CodeSandbox shows the bug. |
I understand what is causing the issue, I identified that myself in my initial comment. The
This is no longer true and causes unexpected behavior. There is no mention of a It's also an undocumented breaking change for anyone using |
@IHIutch Other than the CSB mistake, I was not pointing out causation. I provided what I thought was the reasoning for the omission of breakpoints. I do not know the reasoning as I did not implement the change. I did not close the issue for that reason. If the omission was intentional, then I agree it would be a breaking change that the documentation should have reflected. However, I believe it's simply an unintentional omission that will require either adding breakpoints to the Appreciate your time and effort on this. |
@primos63 Yeah, no worries. I appreciate your comment, I was hoping accurately capture the new change (and in my case, breaking change). |
I've upgraded from |
Description
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
Chakra UI Version
1.6.12
Browser
Chrome Version 95.0.4638.69 (Official Build) (x86_64)
Operating System
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
The text was updated successfully, but these errors were encountered: