scalajs中的无状态反应成分 - 反应

时间:2016-10-08 07:02:41

标签: scalajs-react

在scalajs-react中编写这个({value}) => <li>{value}</li>无状态反应组件的最简单方法是什么?

我在网上找到了以下相关链接,但他们没有回答这个问题:

https://gitter.im/japgolly/scalajs-react?at=557e2a0dc030cae67ed3a4c3 https://github.com/japgolly/scalajs-react/blob/master/core/src/main/scala/japgolly/scalajs/react/ReactComponentB.scala#L41 https://gitter.im/japgolly/scalajs-react?at=561705054e0fa3e55447ba98 http://www.gitterforum.com/discussion/japgolly-scalajs-react?page=269 https://gitter.im/japgolly/scalajs-react?at=57ae33f90fd99f7041367604

这似乎是最接近答案的:

https://gitter.im/japgolly/scalajs-react?at=575347a19be9c5b637f07a00

case class StatelessProps(name: String)
val stateless = FunctionalComponent((props: StatelessProps) => {
    <.span(s"My name is ${props.name}")
})

我不确定这是否是无状态反应组件。

FunctionalComponentstateless react component相同吗?

好的,似乎是:https://gitter.im/japgolly/scalajs-react?at=575329dc9be9c5b637f074e8

0 个答案:

没有答案