mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
Merge pull request #1558 from ealmloff/link-key-props
Add an readable error when you name a prop key
This commit is contained in:
commit
647815fa6f
1 changed files with 8 additions and 5 deletions
|
@ -701,6 +701,14 @@ Finally, call `.build()` to create the instance of `{name}`.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn field_impl(&self, field: &FieldInfo) -> Result<TokenStream, Error> {
|
pub fn field_impl(&self, field: &FieldInfo) -> Result<TokenStream, Error> {
|
||||||
|
let FieldInfo {
|
||||||
|
name: field_name,
|
||||||
|
ty: field_type,
|
||||||
|
..
|
||||||
|
} = field;
|
||||||
|
if *field_name == "key" {
|
||||||
|
return Err(Error::new_spanned(field_name, "Naming a prop `key` is not allowed because the name can conflict with the built in key attribute. See https://dioxuslabs.com/learn/0.4/reference/dynamic_rendering#rendering-lists for more information about keys"));
|
||||||
|
}
|
||||||
let StructInfo {
|
let StructInfo {
|
||||||
ref builder_name, ..
|
ref builder_name, ..
|
||||||
} = *self;
|
} = *self;
|
||||||
|
@ -715,11 +723,6 @@ Finally, call `.build()` to create the instance of `{name}`.
|
||||||
});
|
});
|
||||||
let reconstructing = self.included_fields().map(|f| f.name);
|
let reconstructing = self.included_fields().map(|f| f.name);
|
||||||
|
|
||||||
let FieldInfo {
|
|
||||||
name: field_name,
|
|
||||||
ty: field_type,
|
|
||||||
..
|
|
||||||
} = field;
|
|
||||||
let mut ty_generics: Vec<syn::GenericArgument> = self
|
let mut ty_generics: Vec<syn::GenericArgument> = self
|
||||||
.generics
|
.generics
|
||||||
.params
|
.params
|
||||||
|
|
Loading…
Reference in a new issue