Skip to content

Commit

Permalink
fix(core): assign refs without reactivity during SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens committed Jan 31, 2024
1 parent 077cc16 commit 408576e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/qwik/src/core/container/container.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { qError, QError_invalidRefValue } from '../error/error';
import type { ResourceReturnInternal, SubscriberEffect } from '../use/use-task';
import { seal } from '../util/qdev';
import { isFunction, isObject } from '../util/types';
import { isFunction } from '../util/types';
import type { QRL } from '../qrl/qrl.public';
import { fromKebabToCamelCase } from '../util/case';
import { QContainerAttr } from '../util/markers';
Expand All @@ -11,9 +11,10 @@ import {
type SubscriberSignal,
type SubscriptionManager,
} from '../state/common';
import type { Signal } from '../state/signal';
import { isSignal, type Signal, type SignalImpl } from '../state/signal';
import { directGetAttribute } from '../render/fast-calls';
import type { QContext } from '../state/context';
import { isServerPlatform } from '../platform/platform';

export type GetObject = (id: string) => any;
export type GetObjID = (obj: any) => string | null;
Expand Down Expand Up @@ -147,8 +148,12 @@ export const removeContainerState = (containerEl: Element) => {
export const setRef = (value: any, elm: Element) => {
if (isFunction(value)) {
return value(elm);
} else if (isObject(value)) {
if ('value' in value) {
} else if (isSignal(value)) {
if (isServerPlatform()) {
// During SSR, assigning a ref should not cause reactivity because
// the expectation is that the ref is filled in on the client
return ((value as SignalImpl<Element>).untrackedValue = elm);
} else {
return ((value as Signal<Element>).value = elm);
}
}
Expand Down

0 comments on commit 408576e

Please sign in to comment.