-
-
Notifications
You must be signed in to change notification settings - Fork 57
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 16.6 feature support #196
Comments
|
The remaining two features are generally pretty incompatible with Scala (typing) / Scala.js (dynamic imports), so going to close this issue for now. |
@shadaj I'm wondering does it make sense to reopen this for enabling My slinky app is starting to get slooow, so I was hoping to use React.lazy presuming scalajs-bundler can handle the extra bundles it generates! Would you still consider this improvement? |
@shadaj any words of wisdom how I could go about contributing a react Lazy support? Where in the code base might I refer to for how similar functionality is implemented? I'm not sure what your schedule is, but I don't think there's any other way to progressively load a slinky app other than enabling this feature so I might give it a try since I'm in desperate need! Thanks for reopening :) |
@shadaj where I'm a bit stuck implementing a facade for |
Okay, I think I have a working implementation of Here's what I got so far: trait LazyResult[P] extends js.Object {
val default: FunctionalComponent[P]
}
@js.native
@JSImport("react", JSImport.Namespace, "React")
object ReactShim extends js.Object {
final def `lazy`[P](f: js.Function0[js.Promise[LazyResult[P]]]): FunctionalComponent[P] = js.native
} The only awkward bit is the props require you to explicitly instantiate the @react
object App {
type Props = Unit
val other = ReactShim.`lazy`(() => js.dynamicImport(new LazyResult[Other.Props]{
override val default = Other.component
}))
val component = FunctionalComponent[Props] { props =>
val (show, setShow) = useState[Boolean](false)
div(
"Hey!",
button(onClick := (() => setShow(true))),
if (show) {
other(Other.Props("hello"))
} else {
Nil
}
)
}
} |
React.memo
(more generally, explore functional component support?)React.lazy
(deferred indefinitely, does this have meaning in Scala.js where bundle splitting does not exist?)static contextType
(deferred indefinitely due to complex typing requirements, ping me if you need this!)static getDerivedStateFromError
(in 0.5.1)Suspense
component (in 0.5.1)The text was updated successfully, but these errors were encountered: