facebook / stylex

StyleX is the styling system for ambitious user interfaces.

Home Page:https://stylexjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Create a Vue project using vite: npm create vue@latest
  2. Install @stylexjs/stylex
  3. Install vite-plugin-stylex and add this plugin to vite.config.js:
+import styleX from 'vite-plugin-stylex`;
export default defineConfig({
-  plugins: [vue()],
+  plugins: [vue(), styleX()],
});
  1. Create a component (ie. Button) which should pass a prop to process it later by styleX like this styleX.attrs(variants[variant])
  2. 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.