Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E0061 when trying to call a component without props in Builder API #415

Closed
Dragonink opened this issue May 4, 2022 · 1 comment · Fixed by #431
Closed

E0061 when trying to call a component without props in Builder API #415

Dragonink opened this issue May 4, 2022 · 1 comment · Fixed by #431
Labels
C-bug Category: bug, something isn't working
Milestone

Comments

@Dragonink
Copy link

Describe the bug
I get the Rust error this function takes 2 arguments but 1 argument was supplied when trying to call a component without props with the Builder API.

To Reproduce

#[component]
fn App<G: Html>(cx: Scope) -> View<G> {
	// ...
}
#[wasm_bindgen(start)]
pub fn start() {
	sycamore::render(|cx| App(cx)); // ERROR
	sycamore::render(|cx| App(cx, ())); // WORKS
}

Expected behavior
I expect to be able to call the component like a normal function, as I was able to in the previous version.

Environment

  • Sycamore: 0.8.0-beta.5
@Dragonink Dragonink added the C-bug Category: bug, something isn't working label May 4, 2022
@mc1098
Copy link
Contributor

mc1098 commented May 8, 2022

This part of the #[component] macro code

// If only 1 argument, add an additional argument of type `()`.
if inputs.len() == 1 {
sig.inputs.push(parse_quote! { _: () });
}

was added in 881cddb.
That commit made empty props implicit for the component definition but made it explicit when calling the component - I'm not sure if there was a reason behind making it explicit that I'm not aware of but @lukechu10 would know :)

If this can be changed then from my quick scan of the macro code I think we'd just need to remove those few lines I linked above 🤔.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug, something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants