-
-
Save dispalt/741121b9e90fc0969bcd5a2292a348f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package slinky.core | |
import slinky.core.facade.ReactElement | |
import scala.scalajs.js | |
object FnComponent { | |
@inline def apply[P](fn: P => ReactElement)(implicit name: FunctionalComponentName): FunctionalComponent[P] = { | |
val ret: js.Function1[js.Object, ReactElement] = (obj: js.Object) => { | |
fn(obj.asInstanceOf[js.Dynamic].__.asInstanceOf[P]) | |
} | |
if (scala.scalajs.LinkingInfo.developmentMode) { | |
ret.asInstanceOf[js.Dynamic].displayName = name.name | |
} | |
new FunctionalComponent[P](ret) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment