-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
|
This specific error is happening because the compiler is not configured correctly. I cannot help further without know the details of how your project is set up. You should be able to use the NextJS example in the repo as a template to get started. But also, the code you have written won't work anyway. It's using very dynamic patterns that don't work with a compile-time approach. You cannot do this: const styles = stylex.create({
button: (theme, variant, color, state = 'normal') => ({
...getButtonStyles(theme, variant, color, state)
}),
});StyleX is a compiler. Only use functions within What you're trying to achieve is much easier and more readable if you do it the way StyleX wants you to:
Don't overcomplicate things. Keep things simple. Write styles locally in static objects. Use them. |
Beta Was this translation helpful? Give feedback.
-
|
'stylex.create' should never be called at runtime. It should be compiled away by '@stylexjs/babel-plugin' I face the same error in my react app I don't understand, why is not working in my app can you help me find a solution to this? `import * as stylex from '@stylexjs/stylex'; const styles = stylex.create({
HELLO WORLD
`
|
Beta Was this translation helpful? Give feedback.





This specific error is happening because the compiler is not configured correctly. I cannot help further without know the details of how your project is set up. You should be able to use the NextJS example in the repo as a template to get started.
But also, the code you have written won't work anyway. It's using very dynamic patterns that don't work with a compile-time approach.
You cannot do this:
StyleX is a compiler.
stylex.createcalls are compiled away. This means the styles within thestylex.createcall must be statically analysable…