我已经使用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)
}
}