Skip to content

Commit

Permalink
Upgrade scalajs-react to 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
japgolly committed Oct 18, 2015
1 parent e7d6fd8 commit 78fc679
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
20 changes: 10 additions & 10 deletions bench/react-with/src/demo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ object Demo {
@JSExport("main")
def main(): Unit = {
MyStyles.addToDocument()
React.render(TodoApp(), document getElementById "todo")
ReactDOM.render(TodoApp(), document getElementById "todo")
console.log("hello")
}

val TodoList = ReactComponentB[List[String]]("TodoList")
.render(props => {
.render_P(props => {
def createItem(itemText: String) = <.li(itemText)
<.ul(props map createItem)
})
Expand All @@ -39,24 +39,24 @@ object Demo {
ST.mod(_.copy(text = e.target.value))

def handleSubmit(e: ReactEventI) = (
ST.retM(e.preventDefaultIO)
ST.retM(e.preventDefaultCB)

>>
ST.mod(s => State(s.items :+ s.text, "")).liftIO
ST.mod(s => State(s.items :+ s.text, "")).liftCB
)

val TodoApp = ReactComponentB[Unit]("TodoApp")
.initialState(State(Nil, ""))
.renderS(($,_,S) =>
.renderS(($,s) =>
<.div(
MyStyles.outer,
<.h3("TODO"),
TodoList(S.items),
<.form(^.onSubmit ~~> $._runState(handleSubmit))(
TodoList(s.items),
<.form(^.onSubmit ==> $._runState(handleSubmit))(
<.input(
^.onChange ~~> $._runState(acceptChange),
^.value := S.text),
<.button("Add #", S.items.length + 1)
^.onChange ==> $._runState(acceptChange),
^.value := s.text),
<.button("Add #", s.items.length + 1)
)
)
).buildU
Expand Down
20 changes: 10 additions & 10 deletions bench/react-without/src/demo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ object Demo {

@JSExport("main")
def main(): Unit = {
React.render(TodoApp(), document getElementById "todo")
ReactDOM.render(TodoApp(), document getElementById "todo")
console.log("hello")
}

val TodoList = ReactComponentB[List[String]]("TodoList")
.render(props => {
.render_P(props => {
def createItem(itemText: String) = <.li(itemText)
<.ul(props map createItem)
})
Expand All @@ -27,23 +27,23 @@ object Demo {
ST.mod(_.copy(text = e.target.value))

def handleSubmit(e: ReactEventI) = (
ST.retM(e.preventDefaultIO)
ST.retM(e.preventDefaultCB)

>>
ST.mod(s => State(s.items :+ s.text, "")).liftIO
ST.mod(s => State(s.items :+ s.text, "")).liftCB
)

val TodoApp = ReactComponentB[Unit]("TodoApp")
.initialState(State(Nil, ""))
.renderS(($,_,S) =>
.renderS(($,s) =>
<.div(
<.h3("TODO"),
TodoList(S.items),
<.form(^.onSubmit ~~> $._runState(handleSubmit))(
TodoList(s.items),
<.form(^.onSubmit ==> $._runState(handleSubmit))(
<.input(
^.onChange ~~> $._runState(acceptChange),
^.value := S.text),
<.button("Add #", S.items.length + 1)
^.onChange ==> $._runState(acceptChange),
^.value := s.text),
<.button("Add #", s.items.length + 1)
)
)
).buildU
Expand Down
2 changes: 1 addition & 1 deletion ext-react/src/test/scala/scalacss/ReactTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object ReactTest extends TestSuite {
'simple {
val el = <.input(^.`type` := "text", MyStyles.input, ^.defaultValue := "ah")
val html = React.renderToStaticMarkup(el)
assertEq(html, """<input type="text" class="ReactTest_MyStyles-input" value="ah">""")
assertEq(html, """<input type="text" class="ReactTest_MyStyles-input" value="ah"/>""")
}

'addClassName {
Expand Down
15 changes: 8 additions & 7 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ object ScalaCSS extends Build {
val test = m("test")
}
object react {
private def m(n: String) = "com.github.japgolly.scalajs-react" %%%! n % "0.9.1"
val core = m("core")
val test = m("test")
val extra = m("extra")
private def m(n: String) = "com.github.japgolly.scalajs-react" %%%! n % "0.10.0"
val core = m("core")
val test = m("test")
val extra = m("extra")
val extScalaz71 = m("ext-scalaz71")
}
val shapeless = Library("com.chuusai", "shapeless", "2.2.2")

Expand Down Expand Up @@ -84,8 +85,8 @@ object ScalaCSS extends Build {
.dependsOn(coreJs)
.settings(
libraryDependencies ++= Seq(react.core, react.test % "test"),
jsDependencies +=
"org.webjars" % "react" % "0.12.2" % "test" / "react-with-addons.js" commonJSName "React")
jsDependencies += "org.webjars.npm" % "react" % "0.14.0" % "test" / "react-with-addons.js" commonJSName "React" minified "react-with-addons.min.js",
jsDependencies += "org.webjars.npm" % "react-dom" % "0.14.0" % "test" / "react-dom.js" commonJSName "ReactDOM" minified "react-dom.min.js" dependsOn "react-with-addons.js")

// ==============================================================================================
private def benchModule(name: String, dir: File => File) =
Expand All @@ -97,7 +98,7 @@ object ScalaCSS extends Build {
.enablePlugins(ScalaJSPlugin)
.settings(
scalaSource in Compile := baseDirectory.value / "src",
libraryDependencies += react.extra)
libraryDependencies ++= Seq(react.extra, react.extScalaz71))

val intfmt = java.text.NumberFormat.getIntegerInstance

Expand Down
2 changes: 1 addition & 1 deletion project/PhantomJS2Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PhantomJS2Env(jettyClassLoader: ClassLoader,
override protected def vmName: String = "PhantomJS2"

private val consoleNuker = new MemVirtualJSFile("consoleNuker.js")
.withContent("console.error = undefined;")
.withContent("console.error = console.log;")

override protected def customInitFiles(): Seq[VirtualJSFile] =
super.customInitFiles() :+ consoleNuker
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")

Expand Down

0 comments on commit 78fc679

Please sign in to comment.