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

Add failing test for with props misuse #664

Closed
jstarry opened this issue Sep 27, 2019 · 6 comments
Closed

Add failing test for with props misuse #664

jstarry opened this issue Sep 27, 2019 · 6 comments

Comments

@jstarry
Copy link
Member

jstarry commented Sep 27, 2019

When rendering components with the html! macro, with props can be used to simplify passing props to a component. This approach can not be used with the other approach of passing props one by one. We should have a test that fails when two approaches are combined to make sure the compile error message is nice!

with props approach

html! {
  <MyComponent with props />
}

list props approach

html! {
  <MyComponent value=1 name="hello" />
}

not allowed

html! {
  <MyComponent with props value=1 />
}

Note that there is an exception. Since ref is a special tag, it is still allowed in conjunction with with props. It must come after with props though.

html! {
  <MyComponent with props ref=..  />
}
@captain-yossarian
Copy link
Contributor

@jstarry Is this good place to add tests ?

@jstarry
Copy link
Member Author

jstarry commented Feb 20, 2020

@captain-yossarian not quite. The goal of this issue is to make sure that compiler error messages are helpful and we put those types of tests here. So a good place would be here: https://github.com/yewstack/yew/blob/master/tests/macro/html-component-fail.rs#L60

@jstarry
Copy link
Member Author

jstarry commented Feb 20, 2020

@captain-yossarian I just updated the issue description. It was a bit outdated and didn't call out ref as a special case. We specifically need tests that warn against these cases:

html! {
  <MyComponent with props value=1 />
}
html! {
  <MyComponent value=1 with props />
}

And it would be great if the error message explained that the value=1 syntax and with props syntax are not allowed together

@captain-yossarian
Copy link
Contributor

I have a problem with tests :(

@joaquindk
Copy link
Contributor

@jstarry @captain-yossarian Is this still an issue after #960 being merged?

@jstarry
Copy link
Member Author

jstarry commented Apr 24, 2020

Nope it's fixed. thanks

@jstarry jstarry closed this as completed Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants