Vue3 default prop (string) value is wrapped in quotes
See original GitHub issueDescribe the bug When using a default value for a string type prop, like the below example, Storybook will wrap it in quotes failing the validation and breaking the component.
defaultOrder: {
type: String,
default: 'desc',
validator: (value: string) => ['desc', 'asc'].includes(value),
},
This results in the following control:
Which is actually the string "desc"
instead of just desc
, breaking the component.
To Reproduce Add my prop to a component and create a story for it.
Expected behavior The string value to not be wrapped.
Screenshots See above.
System
System:
OS: macOS 11.2.1
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v12.19.0/bin/yarn
npm: 6.14.10 - ~/.nvm/versions/node/v12.19.0/bin/npm
Browsers:
Chrome: 88.0.4324.192
Edge: 88.0.705.74
Firefox: 81.0.2
Safari: 14.0.3
npmPackages:
@storybook/addon-actions: ^6.2.0-beta.2 => 6.2.0-beta.2
@storybook/addon-essentials: ^6.2.0-beta.2 => 6.2.0-beta.2
@storybook/addon-links: ^6.2.0-beta.2 => 6.2.0-beta.2
@storybook/vue3: ^6.2.0-beta.2 => 6.2.0-beta.2
Additional context We’re using MDX files for the stories, not sure if this also happens in regular story JS files.
┆Issue is synchronized with this Asana task by Unito
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
vue.js - Vuejs component props as string
If you want to specify a string value in that inline expression, you can wrap the value in quotes to make it a...
Read more >Props | Vue.js
All props are optional by default, unless required: true is specified. · An absent optional prop other than Boolean will have undefined value....
Read more >Guide to Vue Props
In this guide, learn what Vue props are, how to register and use them, how to pass data using props, validate them, set...
Read more >How to use variables in CSS with v-bind in VueJs 3
The variable need to be wrapped into a v-bind method. ... me</button> </template> <script> export default { props: { colour: String } ...
Read more >Vue 3 Script Setup, The Future Of Vue? Tutorial And Setup
Vue.js has a new Script Setup feature that is changing the way you create Vue apps. Should you use it? In this video...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
All working, excellent work!
Okay I found that if I strictly type my property it does work, so there must be some TS magic happening: