Dynamic change of props not triggering styleX updates in Vue projects
rubtsovi opened this issue · comments
Describe the issue
When using the styleX in Vue projects, it appears that dynamic changes to props do not trigger updates in the generated styles.
Expected behavior
Dynamic changes to prop value should trigger the application of appropriate styles.
Steps to reproduce
- Create a Vue project using vite:
npm create vue@latest
- Install
@stylexjs/stylex
- Install
vite-plugin-stylex
and add this plugin tovite.config.js
:
+import styleX from 'vite-plugin-stylex`;
export default defineConfig({
- plugins: [vue()],
+ plugins: [vue(), styleX()],
});
- Create a component (ie. Button) which should pass a prop to process it later by styleX like this
styleX.attrs(variants[variant])
- Change dynamically passed prop (via debug tool, or by clicking this button)
Test case
Here I prepared the case: codesandbox
Additional comments
I tested the same with Vite + React - and it works perfectly, so assumed that the problem is not in vite-plugin-stylex
My bad :/ I used props destructuring, so it did not work for dynamic props. If I pass prop to the styleX like that stylex.attrs(variants[props.variant])
it works perfectly. Closing issue.
I guess Vue props are similar to Solid where de-structuring can't be used.