Subscribe on changes!

After upgrading to vuejs version 3.4, I see the message `useComputedClass must be called within a component setup function.`

avatar
Jan 4th 2024

Vue version

3.4.0 - 3.4.5

Link to minimal reproduction

https://github.com/homagix/homagix-frontend

Steps to reproduce

git clone https://github.com/jschirrmacher/homagix-frontend.git npm i vue@3.4.5 npm run test:unit

What is expected?

Executing the unit tests should succeed.

What is actually happening?

When tests are run with vuejs 3.3.13, all works well.

After upgrading to vue 3.4.0 (or 3.4.5), I get an error message

useComputedClass must be called within a component setup function.

and before that a warning (which I don't know if that is related):

Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core

Downgrading to vue 3.3.13 lets the tests succeed again, so it seems to be related to this release.

System Info

System:
    OS: macOS 13.6.3
    CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
    Memory: 236.71 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nodenv/versions/18.12.1/bin/node
    npm: 8.19.2 - ~/.nodenv/versions/18.12.1/bin/npm
  Browsers:
    Chrome: 120.0.6099.199
    Safari: 17.2.1
  npmPackages:
    vue: ^3.4.5 => 3.4.5

Any additional comments?

No response

avatar
Jan 4th 2024

There is also a Stackoverflow question seeing this same error with other code.

What is in common is, that it also uses Oruga. Might be related to this as well.

avatar
Jan 5th 2024

This is the reason for oruga. I noticed that they used useComputedClass extensively in compute. v3.4 has made enhancements in the reactivity system, which may have caused this problem. https://github.com/oruga-ui/oruga/issues/709

I followed the writing method of oruga. There is no recurrence problem in the playground. You may need to provide a repository that can reproduce the problem.

avatar
Jan 5th 2024

relateļ¼š#9974

avatar
Jan 7th 2024

this is related to oruga, not vue. author must fix his library use-hooks

avatar
Jan 8th 2024

I've added a warning if getCurrentInstance() is called inside a computed getter in https://github.com/vuejs/core/commit/324e817ef8d00c091e5d1537789542241c876d66

The usage is incorrect and should be fixed in oruga.