input: JSX elements cannot have multiple attributes with the same name.
See original GitHub issueThe recent update made my build crash. The Error is:
ts(17001): JSX elements cannot have multiple attributes with the same name.
It’s an input whose type is either “radio” or “checkbox” with a v-model and a value. Obviously, those 2 are allowed for these types. Only for other inputs, it would be a duplication
<input type="myType" v-model="foo" :value="bar" />
defineProps({
myType: {
type: String as PropType<'radio' | 'checkbox'>
}
}
Volar seems to handle this case as a regular input even tho the type of type (haha) is radio or checkbox.
Possible Solution
If you know that your input is a checkbox or radiobox, dont use v-model.
Instead use :checked="foo"
and @change="foo = $event.target.checked"
That will solve the duplication because volar seems to handle v-model as :value instead of :checked.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:22 (15 by maintainers)
Top Results From Across the Web
Attempting to render to multiple attributes to a single JSX ...
I want to iterate through both arrays and render data from both to the same image element. I successfully iterated over a single...
Read more >How to handle multiple attributes in ReactJS - Nikita Hlopov
You can store all of the attributes in an object and use Spread syntax on the element to assign them. render () {...
Read more >Attributes that work differently between React and HTML
We can't use the attributes with the same name in both React and HTML because when the code is rendered in React, JSX...
Read more >JSX In Depth - React
Specifying The React Element Type The first part of a JSX tag determines the type of the React element. Capitalized types indicate that...
Read more >jsx elements cannot have multiple attributes with the same name
jsx elements cannot have multiple attributes with the same name · Oops, You will need to install Grepper and log-in to perform this...
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
Wow - I INSTANTLY found the issue when using this. In the virtual file, standalone attributes have the value
(true)
. Unfortunetaly, using “true” instead of “null” didnt work either. Maybe because it is treated as a special value? I dont know. The empty string works and is fine for nowWe could simply allow passing an array: