japgolly / scalajs-react

Facebook's React on Scala.JS
https://japgolly.github.io/scalajs-react/
Apache License 2.0
1.64k stars 231 forks source link

Support displayName in Scala functional components #1092

Closed rpiaggio closed 3 months ago

rpiaggio commented 4 months ago

Example:

  ScalaFnComponent.withDisplayName("MyComponent")
    .withHooks[Props]
    .useState(0)
    .render((_, s) => s.value.toString)

I disabled Mima checks temporarily since this is binary incompatible (it is source compatible though). This implies we have to step up to 2.2.0. We have to reenable Mima tests after 2.2.0 release. This will go into a 3.0.0 release, together with React 18 support.

Thanks to @hugo-vrijswijk for the idea of using sourcecode.FullName for the default names.

rpiaggio commented 3 months ago

Since this implementation breaks binary compatibility, it would actually imply a major version bump (ie: 3.0.0).

Seems overkill just for this change, so I'm going to merge this change to our React 18 branch and release this feature there.