0

I've been using scalajs-react for a couple of weeks and so far I've never used the "children" parameter of ReactComponentC.apply() because my children ReactNodes are usually conditionally defined in c.backend.render(). Am I doing something wrong? I there an advantage with passing the children nodes in ReactComponentC.apply()? I there any way to modify this children list dynamically after ReactComponentC.apply() has been run?

Basically I'm just wondering what's the advantage of passing a child to ReactComponentB versus creating an instance of ReactComponentB within the render method of the father component. For instance:

    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)
  }
}
stackoverflowed
  • 686
  • 8
  • 22
  • For those wondering how to create a component that accept children: https://github.com/japgolly/scalajs-react/issues/83#issuecomment-1064872840 – stackoverflowed Mar 11 '22 at 08:12

1 Answers1

0

I'm not 100% sure what you mean. 1.0.0-RC1 has just been released and children are handled differently now anyway. If you upgrade to it, read the new TYPES.md and changelog you might find that this question has become obsolete...?

Golly
  • 1,319
  • 8
  • 18
  • Thanks for that, I'm gonna update to 1.0.0. But I think my question is still relevant for 1.0.0. I added a bit of clarification to my question above. – stackoverflowed Mar 09 '17 at 07:08