Comments (7)
Ah, this is due to the React Native bindings using the @react
annotation, which isn't supported on Scala 3. You may have better luck with the ScalablyTyped bindings, there's a good chance those will become the recommended approach soon anyways.
from slinky.
This is the only Scala 3 issue I've found open and I'd like to clarify: is this the minimal example on how to compile a component with Slinky in Scala 3 and react (native)?:
package example
import example.app.App
import org.scalajs.dom
import org.scalajs.dom.document
import slinky.core.FunctionalComponent
import slinky.core.facade.{React, ReactElement}
import slinky.web.ReactDOM
import slinky.web.html.{div, h1}
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@main
def Example(): Unit = {
ReactDOM.render(App.component(App.Props()), dom.document.getElementById("root"))
}
where App is:
package example.app
import slinky.core.FunctionalComponent
import slinky.web.html.h1
object App {
case class Props()
val component = FunctionalComponent[Props] { props =>
h1(s"Hello, slinky!")
}
}
Would be great if there's a more succinct approach, like still being able to achieve @react
's fancy .apply
look and feel!
from slinky.
Yep, unfortunately for now there's no way to get the nice apply
implementations since there is no support for macros that introduce new APIs.
from slinky.
How should ExternalComponent
be handled in Scala 3?
Update
Super simple! So instead of MyComp.component(MyComp.Props(..))
it's just calling the apply
method: MyComp(MyComp.Props(..))
from slinky.
This is a good point. For now we could just make @react
a no-op on Scala 3.
Then again, I've been considering deprecating the React Native bindings entirely in favor of ScalablyTyped ones, which are more up to date and work across Scala 2/3.
from slinky.
Another big Scala3 feature yet to be supported: Reader
and Writer
Currently if you try to Read
or Write
using case classes, the macro will fail to capture the js.Object
, failing in some way like:
TypeError: null is not an object (evaluating '$thiz.forceRead__sjs_js_Object__O')
As a best effort, I still use Reader
and Writer
but only with js.Object
, not case classes. It defeats the purpose but maintains a consistent API for when these are eventually supported for Scala 3
from slinky.
ouch! Just hit a very hard to catch incompatibility with Scala3:
the children: ReactElement*
Prop does not correctly produce a Seq[ReactElement]
if you pass a Seq[ReactElement]
for that argument. What happens is it produces something like Seq(Fragment(children))
, so a Seq
but always of length 1!!
So be sure to always define children: Seq[ReactElement]
for all elements to be properly passed. Both compile, but only that approach correctly preserves the list structure.
from slinky.
Related Issues (20)
- Support svg or arbitrary tags and attributes HOT 2
- Support for drag and drop synthetic events HOT 2
- Scala 3 onChange SyntheticEvent with unexpected higher kinds
- SVG circle cx, cy attributes dont support string HOT 1
- ERR_OSSL_EVP_UNSUPPORTED HOT 3
- Add type and props to ReactElement to permit restricting child type
- unused value of type Props with @react macro
- IntelliJ plugin throws IncompatibleClassChangeError HOT 2
- IntelliJ plugin doesn't recognise multiple parameter lists
- Multiple parameter lists are not supported
- Tag support for Scala 3 HOT 1
- java.lang.IncompatibleClassChangeError in IntelliJ plugin HOT 2
- slinky-hot prevents to load pages in Scala 3 HOT 5
- Add support for ReactDOM createRoot HOT 1
- Trouble setting onBeforeInput handler HOT 2
- Synatic sugar for setting event handlers with useCapture HOT 5
- `@react` macro generated value names conflict with those from slinky.web.html on 2.13.13
- `@react` macro annotation for Scala 3.5.0 HOT 2
- Using fallback derivation messages are not suppressible
- Children are not correctly handled when not varargs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slinky.