Composables usage restrictions #7488
Mini-ghost
started this conversation in
General Discussions
Replies: 1 comment 3 replies
-
Another related topic, I'd like some discussion on using a composable outside of the vue setup function. IMO, this should not happen, however I know some people would disagree.
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to know what everyone think about those usage restrictions of composable. Those usage restrictions are imentioned in the official documentation, but I found many cases where those restrictions are not respected.
The following is excerpted from the documentation:
https://github.com/vuejs/docs/blob/e39b5d1175d476170319adf7c916abd4820800c0/src/guide/reusability/composables.md?plain=1#L278-L290
According to the content, we SHOULT NOT use the composable API like following examples.
Example 1
Example 2
Example 3
Some great libraries (such as: VueUse ) has handled those misuses so that they don't lead to major errors. But we can't guarantee that every community projects can handle this issue properly, so i have some suggestions:
I'm not sure if this is taken seriously, but I think following it will reduces the mental load of understanding the code.
I'd like to hear your opinions on this suggestion, Thanks!
Beta Was this translation helpful? Give feedback.
All reactions