Given the following file structure
app.css
@import https://bla.css html { --green: #ff0; } html { --red: #f00; } How do I read --red?
Already tried
app.tsx
... useLayoutEffect(() => { // works const green = getComputedStyle(document.documentElement) .getPropertyValue('--green'); // doesn't work const red = getComputeStyle(document.documentElement) .getPropertyValue('--red'); }) I've already tried waiting for frames with setTimeout and requestAnimationFrame to no avail. If I setTimeout(() => {...}, 10000) the variable is there so I know it's only a synchronisation issue, but I have no idea on how to get the update.
没有评论:
发表评论