如何将子节点传递给ReactComponent

时间:2017-02-23 09:35:42

标签: scalajs-react

我已经使用scalajs反应了几个星期,到目前为止,我从未使用过"孩子" ReactComponentC.apply()的参数,因为我的孩子ReactNodes通常在c.backend.render()中有条件地定义。 难道我做错了什么?我在ReactComponentC.apply()中传递子节点有什么优势?我有没有办法在ReactComponentC.apply()运行后动态修改这个子列表?

基本上我只是想知道将子传递给ReactComponentB与在父组件的render方法中创建ReactComponentB实例的优点是什么。 例如:

    class Backend($: BackendScope[Props, State]) { //The backend class of the father
  def render(p: Props, s: State) = {
     ReactComponentB("Child") //I create the child directly in the render method (I didn't pass it as a Child.Varargs)
  }
}

1 个答案:

答案 0 :(得分:0)

我不是100%肯定你的意思。 1.0.0-RC1刚刚发布,现在孩子的处理方式也不同了。如果你升级到它,请阅读新的TYPES.mdchangelog,你可能会发现这个问题已经过时了......?