Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/react-router/src/link.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,9 +166,6 @@ export function useLinkProps<
const router = useRouter()
const innerRef = useForwardedRef(forwardedRef)

// Determine if we're on the server - used for tree-shaking client-only code
const _isServer = isServer ?? router.isServer

const {
// custom props
activeProps,
Expand DownExpand Up@@ -220,7 +217,9 @@ export function useLinkProps<
//
// Note: `location.hash` is not available on the server.
// ==========================================================================
if (_isServer) {
// The expression must stay inlined in the `if` so bundlers fold the
// browser-build constant `isServer = false` and drop this server block.
if (isServer ?? router.isServer) {
const safeInternal = isSafeInternal(to)

// If `to` is obviously an absolute URL, treat as external and avoid
Expand Down
5 changes: 3 additions & 2 deletions packages/react-router/src/useRouterState.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,8 +56,9 @@ export function useRouterState<

// During SSR we render exactly once and do not need reactivity.
// Avoid subscribing to the store (and any structural sharing work) on the server.
const _isServer = isServer ?? router.isServer
if (_isServer) {
// The expression must stay inlined in the `if` so bundlers fold the
// browser-build constant `isServer = false` and drop this server block.
if (isServer ?? router.isServer) {
const state = router.stores.__store.get() as RouterState<
TRouter['routeTree']
>
Expand Down
5 changes: 3 additions & 2 deletions packages/solid-router/src/useRouterState.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,8 +33,9 @@ export function useRouterState<
// During SSR we render exactly once and do not need reactivity.
// Avoid subscribing to the store on the server since the server store
// implementation does not provide subscribe() semantics.
const _isServer = isServer ?? router.isServer
if (_isServer) {
// The expression must stay inlined in the `if` so bundlers fold the
// browser-build constant `isServer = false` and drop this server block.
if (isServer ?? router.isServer) {
const state = router.stores.__store.get() as RouterState<
TRouter['routeTree']
>
Expand Down
6 changes: 3 additions & 3 deletions packages/vue-router/src/useRouterState.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ export function useRouterState<
// During SSR we render exactly once and do not need reactivity.
// Avoid subscribing to the store on the server since the server store
// implementation does not provide subscribe() semantics.
const _isServer = isServer ?? router.isServer

if (_isServer) {
// The expression must stay inlined in the `if` so bundlers fold the
// browser-build constant `isServer = false` and drop this server block.
if (isServer ?? router.isServer) {
const state = router.stores.__store.get() as RouterState<
TRouter['routeTree']
>
Expand Down
Loading