Skip to content

BUG: useEffectOnMount not fired when withPropsChildren hook is used #1112

@Angel-O

Description

@Angel-O

Versions

  • scalajs-react version: 3.0.0-beta12
  • react version: 19.0.0

Bug

Not sure if this is the intended behavior (I searched the official React docs but couldn't see any mention of this behavior)

.useEffectOnMount doesn't work when used in conjunction with the .withPropsChildren hook.

Here's a minimal reproducible example

object Bug extends App {

  val component = ScalaFnComponent
    .withHooks[Unit]
    .withPropsChildren
    .useEffectOnMount {
      Callback.log("useEffectOnMount not fired!") //  won't run ...
    }
    .render(_.propsChildren)

  ReactDOMClient
    .createRoot(document.querySelector("#app"))
    .render(component(<.div("hi there")))
}

If we remove the .withPropsChildren hook instead the effect runs

object NoBug extends App {

  val component = ScalaFnComponent
    .withHooks[Unit]
    .useEffectOnMount {
      Callback.log("useEffectOnMount is fired!") // will run
    }
    .render(_ => <.div("hi there"))

  ReactDOMClient
    .createRoot(document.querySelector("#app"))
    .render(component())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions