useAssets doesn't work in Astro #1935
Unanswered
wakaztahir
asked this question in
Q&A
Replies: 1 comment
-
The hook doesn't work in Astro Here's how I am using it createRenderEffect((prev) => {
const elemId = componentId
if(isServer) {
useAssets(() => (
<style id={elemId} nonce={context.cache?.nonce}>{`.${className}{${rulesString}}`}</style>
))
return null
} else {
// let find = document.getElementById(elemId)
// if(!find) {
// find = document.head.appendChild(document.createElement("style"))
// }
// find.nonce = context.cache?.nonce
// find.id = elemId
// find.innerHTML = `.${className}{${rulesString}}`
// return find
console.warn("dom style appending is turned off")
return null
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I used this useAssets hook to put styles into the head element automatically
Here it works in solid-start but this hook doesn't work in Astro
https://stackblitz.com/edit/solid-ssr-vite-ke7ixp?file=src%2Froutes%2Findex.tsx
Beta Was this translation helpful? Give feedback.
All reactions