-
Notifications
You must be signed in to change notification settings - Fork 13
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
Shorter prop usage syntax #20
Comments
React.renderComponent() is not happy with the method, I have to cast the component to ReactDOM before invoking the renderComponent(). It's no big deal and it works but I am pretty sure it could be improved with a different signature, visible as ReactDOM (<%) instead of extending ReactDOM (<:) not sure about the side effects though.
|
I just extracted the type and the implicit into a trait and I am pretty happy with the syntax now :
This little trait make this possible :
Best, |
Damned :) This solution pose a problem with optional case class parameters, more work is needed.
Also in some cases the @scalax fail to cast the property class into a ReactDom which is cumbersome. |
Hello,
I've been using the project for some days and was really pleased by the lib except for the syntax part which suffer from react/js legacy.
The problem with Props() is that it forces you to type a lot of things and when you start to use apply(...) = apply(Props(...)) you have to type three times your parameters to keep things in sync which is a pain.
I just found a method to shorten the syntax but I haven't tested it a lot so your comments are welcome :
And then you can instantiate your component just like with the regular Component.apply(...) method :
Maybe the implicit can be pushed up into the hierarchy so users don't have to type it everytime or maybe the case class type could be given as a generic parameter so the implicit could be created inside the TypedReactSpec[T]. I am not sure what could work with the project.
There may be problems with Seq[Component], I am not sure implicits will be run correctly to get Seq[ReactDom], I haven't tested it yet and you may see problems coming :)
Anyway thank you for the awesome work and I hope this little trick will be of some help to simplify the API.
The text was updated successfully, but these errors were encountered: