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
2 changes: 1 addition & 1 deletion apps/playground-app/src/shared/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const pageStarted = createEvent<{

export const $currentPage = createStore<(typeof pageTypes)[number] | null>(null).on(
pageStarted,
(_, { pageType }) => pageType
(_, { pageType }) => pageType ?? "unknown_page"
);

export function declarePage<Ctx = void>(config: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"build:code": "vite build",
"build:types": "tsc",
"build:directive": "node ./scripts/inject-use-client.mjs",
"build": "pnpm build:code && pnpm build:types && pnpm build:directive"
"build": "pnpm build:code && pnpm build:types && pnpm build:directive",
"dev:playground-app": "cd apps/playground-app && pnpm dev"
},
"devDependencies": {
"@babel/core": "^7.21.4",
Expand Down
14 changes: 13 additions & 1 deletion src/get-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,19 @@ function HACK_updateScopeRefs(tscope: Scope, values: Values) {
}

/**
* Run scheduled watchers
* Delay links run to separate task,
* so React won't agro on us for updating state during render
*/
queueMicrotask(() => {
HACK_runScopeWatchers(scope, linksToRun);
});
}

function HACK_runScopeWatchers(scope: ScopeInternal, linksToRun: string[]) {
/**
* Run watchers (`useUnit`, etc) to push new values to them
*
* Manual lauch is required because top-down re-render stops at `memo`-ed components
*/
if (linksToRun.length) {
linksToRun.forEach((nodeId) => {
Expand Down