Skip to content

Commit e1f6ce6

Browse files
committed
[ui-react] Ensure global context
1 parent 84bfcc5 commit e1f6ce6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
"transpilations",
164164
"Turso",
165165
"typeof",
166+
"uirc",
166167
"undefinedr",
167168
"unlisten",
168169
"Unstar",

src/ui-react/context.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ import type {
1212
useRelationships as useRelationshipsDecl,
1313
useStore as useStoreDecl,
1414
} from '../@types/ui-react/index.d.ts';
15+
import {GLOBAL, isString, isUndefined} from '../common/other.ts';
1516
import type {Id, Ids} from '../@types/common/index.d.ts';
16-
import {IdObj, objGet, objIds} from '../common/obj.ts';
17-
import {isString, isUndefined} from '../common/other.ts';
17+
import {IdObj, objEnsure, objGet, objIds} from '../common/obj.ts';
1818
import type {Checkpoints} from '../@types/checkpoints/index.d.ts';
1919
import type {Indexes} from '../@types/indexes/index.d.ts';
2020
import type {Metrics} from '../@types/metrics/index.d.ts';
2121
import type {Queries} from '../@types/queries/index.d.ts';
2222
import React from 'react';
2323
import type {Relationships} from '../@types/relationships/index.d.ts';
2424
import type {Store} from '../@types/store/index.d.ts';
25+
import {TINYBASE} from '../common/strings.ts';
2526

2627
const {createContext, useContext, useEffect} = React;
2728

@@ -42,7 +43,11 @@ type ContextValue = [
4243
delExtraStore?: (id: string) => void,
4344
];
4445

45-
export const Context = createContext<ContextValue>([]);
46+
export const Context: React.Context<ContextValue> = objEnsure(
47+
GLOBAL,
48+
TINYBASE + '_uirc',
49+
() => createContext<ContextValue>([]),
50+
);
4651

4752
const useThing = <
4853
Thing extends

0 commit comments

Comments
 (0)