Skip to content

Commit 7f9148c

Browse files
committed
Fix #1112
Hook initialisation was missing entirely
1 parent 54006bc commit 7f9148c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/coreGeneric/src/main/scala/japgolly/scalajs/react/hooks/HookComponentBuilder.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ object HookComponentBuilder {
120120
step.next(init, f)
121121

122122
override def render(f: Ctx => VdomNode)(implicit s: CtorType.Summoner[Box[P], Children.Varargs]): Component[P, s.CT] =
123-
ScalaFn.withChildren((p: P, pc: PropsChildren) => f(HookCtx.withChildren(p, pc)))
123+
ScalaFn.withChildren((p: P, pc: PropsChildren) => {
124+
val h = HookCtx.withChildren(p, pc)
125+
init(h)
126+
f(h)
127+
})
124128

125129
def render(f: (P, PropsChildren) => VdomNode)(implicit s: CtorType.Summoner[Box[P], Children.Varargs]): Component[P, s.CT] =
126-
ScalaFn.withChildren(f)
130+
render((ctx: Ctx) => f(ctx.props, ctx.propsChildren))
127131

128132
override def renderWithReuseBy[A](reusableInputs: Ctx => A)(f: A => VdomNode)(implicit s: CtorType.Summoner[Box[P], Children.Varargs], r: Reusability[A]): Component[P, s.CT] =
129133
customBy(ctx => CustomHook.shouldComponentUpdate(f).apply(() => reusableInputs(ctx)))

0 commit comments

Comments
 (0)