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

@react macro annotation for Scala 3.5.0 #717

Open
steinybot opened this issue Aug 4, 2024 · 2 comments
Open

@react macro annotation for Scala 3.5.0 #717

steinybot opened this issue Aug 4, 2024 · 2 comments

Comments

@steinybot
Copy link
Contributor

It looks like macro annotations can now modify their companion objects in Scala 3.5.0: scala/scala3#19677

@steinybot
Copy link
Contributor Author

Wait a minute... why was I thinking that this needs to go on the props class?

@steinybot
Copy link
Contributor Author

The best solution I can think of which has the fewest breaking changes is to:

  1. Add a scalafix rule which rewrites objects with @react annotations to:
    1. Extract the Props to a companion case class.
    2. Add a parent trait to the object for which a @react macro annotation can implement.
  2. The parent trait defines an abstract given Conversion[Props, KeyAddingStage] (and possibly others to avoid having to chain implicits)
  3. The @react macro annotation implements the given Conversion[Props, KeyAddingStage] using the component.

The exact shape of the props companion case class and member to implement in the companion object needs a bit more thought but this is the basic idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant