You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
734 B

package com.example.playscalajsreact.component
object IntEditor {
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.MonocleReact._
import japgolly.scalajs.react.extra._
import monocle.macros.Lenses
val component = ScalaComponent
.builder[StateSnapshot[Int]]
.render_P { stateSnapshot =>
<.span(
^.paddingLeft := "6ex", // leave some space for ReusabilityOverlay
<.button(
s"Current value is ${stateSnapshot.value}. Click to increment",
^.onClick --> stateSnapshot.modState(_ + 1),
)
)
}
.configure(ReusabilityOverlay.install)
.build
def apply(ss: StateSnapshot[Int]) = component(ss)
}