StateSnapshot example中的主要组件不使用后端,但我需要一个。我的尝试:
class MainBackend($ : BackendScope[Unit, Name]) {
def render(name: Name) = {
val firstNameV = StateSnapshot.zoomL(Name.firstName).of(name)
val surnameV = StateSnapshot.zoomL(Name.surname).of(name)
<.div(
<.label("First name:", NameChanger(firstNameV)),
<.label("Surname:", NameChanger(surnameV)),
<.p(s"My name is ${name.surname}, ${name.firstName} ${name.surname}.")
)
}
}
val Main = ScalaComponent
.builder[Unit]("StateSnapshot example")
.initialState(Name("John", "Wick"))
.renderBackend[MainBackend]
.build
我在行value firstName is not a member of object app.TreeView.Name
中收到编译错误val surnameV = StateSnapshot.zoomL(Name.surname).of(name)
。