Skip to content

Instantly share code, notes, and snippets.

@srid
Last active October 19, 2023 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srid/516764cc35d4442a945ce6564b282d9e to your computer and use it in GitHub Desktop.
Save srid/516764cc35d4442a945ce6564b282d9e to your computer and use it in GitHub Desktop.
Dioxus components cannot have `key` argument?

Apply the below patch on top of https://github.com/srid/dioxus-desktop-template/tree/2500a3729f5909e930bfe33ddd6863844dbef721

image

[ERROR] error[E0061]: this method takes 1 argument but 0 arguments were supplied
   --> src/main.rs:122:5
    |
122 | /     render! {
123 | |         div { class: "flex flex-col items-center",
124 | |             p {
125 | |                 "You are looking at a "
...   |
136 | |         }
137 | |     }
    | |_____^ an argument of type `ExternalLinkPropsBuilder_Error_Missing_required_field_key` is missing
    |
note: method defined here
   --> src/main.rs:165:1
    |
165 | #[component]
    | ^^^^^^^^^^^^
    = note: this error originates in the macro `render` which comes from the expansion of the derive macro `Props` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the argument
    |
137 |     }(/* ExternalLinkPropsBuilder_Error_Missing_required_field_key */)
    |      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/src/main.rs b/src/main.rs
index 416e948..47c1890 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -126,7 +126,7 @@ fn About(cx: Scope) -> Element {
span { class: "font-bold", "Dioxus" }
" app (see source code "
ExternalLink {
- href: "https://github.com/srid/dioxus-desktop-template",
+ key: "https://github.com/srid/dioxus-desktop-template",
title: "Github repository",
"here"
}
@@ -165,14 +165,14 @@ fn Nav(cx: Scope) -> Element {
#[component]
fn ExternalLink<'a>(
cx: Scope,
- href: &'static str,
+ key: &'static str,
title: &'static str,
children: Element<'a>,
) -> Element {
render! {
a {
class: "text-purple-600 hover:text-purple-800",
- href: "{href}",
+ href: "{key}",
title: "{title}",
children
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment