Skip to content

Commit af40e59

Browse files
committed
fix(solid-router): prevent client effects running on server
1 parent fe01311 commit af40e59

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/solid-router/src/Transitioner.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@tanstack/router-core'
77
import { useRouter } from './useRouter'
88
import { useRouterState } from './useRouterState'
9-
import { usePrevious } from './utils'
9+
import { useLayoutEffect, usePrevious } from './utils'
1010

1111
export function Transitioner() {
1212
const router = useRouter()
@@ -65,8 +65,7 @@ export function Transitioner() {
6565
})
6666

6767
// Try to load the initial location
68-
Solid.createRenderEffect(() => {
69-
if (router.isServer) return
68+
useLayoutEffect(() => {
7069
Solid.untrack(() => {
7170
if (
7271
// if we are hydrating from SSR, loading is triggered in ssr-client
@@ -87,7 +86,7 @@ export function Transitioner() {
8786
})
8887
})
8988

90-
Solid.createRenderEffect(
89+
useLayoutEffect(
9190
Solid.on(
9291
[previousIsLoading, isLoading],
9392
([previousIsLoading, isLoading]) => {
@@ -100,7 +99,8 @@ export function Transitioner() {
10099
},
101100
),
102101
)
103-
Solid.createRenderEffect(
102+
103+
useLayoutEffect(
104104
Solid.on(
105105
[isPagePending, previousIsPagePending],
106106
([isPagePending, previousIsPagePending]) => {
@@ -115,7 +115,7 @@ export function Transitioner() {
115115
),
116116
)
117117

118-
Solid.createRenderEffect(
118+
useLayoutEffect(
119119
Solid.on(
120120
[isAnyPending, previousIsAnyPending],
121121
([isAnyPending, previousIsAnyPending]) => {

0 commit comments

Comments
 (0)