Skip to content

Commit

Permalink
fix createSelector during concurrent rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Jun 24, 2021
1 parent bc93e07 commit 58f05b5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Ow
root: Owner =
fn.length === 0 && !"_SOLID_DEV_"
? UNOWNED
: { owned: null, cleanups: null, context: null, owner, attached: Boolean(detachedOwner) };
: { owned: null, cleanups: null, context: null, owner, attached: !!detachedOwner };

if ("_SOLID_DEV_" && owner) root.name = `${(owner as Computation<any>).name}-r${rootCount++}`;
Owner = root;
Expand Down Expand Up @@ -405,7 +405,7 @@ export function createSelector<T, U>(
undefined,
true,
"_SOLID_DEV_" ? options : undefined
);
) as Memo<any>;
updateComputation(node);
return (key: U) => {
let listener: Computation<any> | null;
Expand All @@ -417,7 +417,10 @@ export function createSelector<T, U>(
l!.size > 1 ? l!.delete(listener!) : subs.delete(key);
});
}
return fn(key, node.value!);
return fn(
key,
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value!
);
};
}

Expand Down Expand Up @@ -585,8 +588,7 @@ export function devComponent<T>(Comp: (props: T) => JSX.Element, props: T) {

export function hashValue(v: any): string {
const s = new Set();
return (
`s${
return `s${
typeof v === "string"
? hash(v)
: hash(
Expand All @@ -597,8 +599,8 @@ export function hashValue(v: any): string {
}
return v;
}) || ""
)}`
);
)
}`;
}

export function registerGraph(name: string, value: { value: unknown }): string {
Expand Down Expand Up @@ -1021,11 +1023,12 @@ function resolveChildren(children: any): unknown {
function createProvider(id: symbol) {
return function provider(props: { value: unknown; children: any }) {
let res;
createComputed(() =>
res = untrack(() => {
Owner!.context = { [id]: props.value };
return children(() => props.children);
})
createComputed(
() =>
(res = untrack(() => {
Owner!.context = { [id]: props.value };
return children(() => props.children);
}))
);
return res as JSX.Element;
};
Expand Down

0 comments on commit 58f05b5

Please sign in to comment.