Created
October 31, 2016 20:56
-
-
Save jhegedus42/97052583284f9c2015b9a8dbc725b21c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
In Scala: | |
@js.native | |
trait Props extends js.Object { | |
val value: String = js.native | |
val items: scala.collection.mutable.Seq[String] = js.native | |
} | |
@JSExport | |
val TestCompB: ReqProps[Props, Unit, Unit, TopNode] = | |
ReactComponentB[Props]("HelloMessage") | |
.render($ => { | |
// val h=$.props.items.head //this does not work | |
val h = $.props.value //this works | |
<.div("Hello " + h) | |
} | |
) | |
.build | |
@JSExport | |
val wrapTestCompB: js.Function1[Props, ReactComponentU[Props, Unit, Unit, TopNode]] = | |
(x: Props) => TestCompB(x) | |
//val TestCompInst: ReactComponentU[String, Unit, Unit, TopNode] = TestCompB("vazzeg") | |
IN JS: | |
// Using Component defined in scalajs | |
const state6 = { items: ['Item 1 jelleig', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'] } | |
const TestComponentS = example.Experiment().wrapTestCompB // Scala.js version | |
var target6 = document.getElementById("playground6") | |
render(<TestComponentS value="shiraly43 - using scalajs component from js" items={state6}/>, target6); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment