From b9ba9de8a52bfb4e279a0643216da95852df9b92 Mon Sep 17 00:00:00 2001 From: Hugo van Rijswijk Date: Wed, 24 Jul 2024 14:40:11 +0200 Subject: [PATCH] Wrap router actions in startTransition --- .../scala/japgolly/scalajs/react/extra/router/Router.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/extra/src/main/scala/japgolly/scalajs/react/extra/router/Router.scala b/library/extra/src/main/scala/japgolly/scalajs/react/extra/router/Router.scala index bba909ee4..579abd0b3 100644 --- a/library/extra/src/main/scala/japgolly/scalajs/react/extra/router/Router.scala +++ b/library/extra/src/main/scala/japgolly/scalajs/react/extra/router/Router.scala @@ -6,6 +6,7 @@ import japgolly.scalajs.react.util.DefaultEffects import japgolly.scalajs.react.util.Effect.Sync import japgolly.scalajs.react.util.Util.identityFn import japgolly.scalajs.react.vdom.VdomElement +import japgolly.scalajs.react.React.startTransition import org.scalajs.dom import scala.scalajs.js @@ -50,7 +51,7 @@ object RouterWithProps { .render ($ => lgc.render($.state, $.props)) .componentDidMount ($ => cfg.postRenderFn(None, $.state.page, $.props)) .componentDidUpdate (i => cfg.postRenderFn(Some(i.prevState.page), i.currentState.page, i.currentProps)) - .configure (ListenableF.listenToUnit(_ => lgc, $ => F.flatMap(lgc.syncToWindowUrl)(s => F.transSync($.setState(s))))) + .configure (ListenableF.listenToUnit(_ => lgc, $ => F.flatMap(lgc.syncToWindowUrl)(s => startTransition(F.transSync($.setState(s)))))) .configure (EL.install_("popstate", lgc.ctl.refresh, dom.window)) .configureWhen(isIE11())(EL.install_("hashchange", lgc.ctl.refresh, dom.window)) }