History

Merge remote-tracking branch 'origin/codex/split-react-scope-context-boundaries' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit ae26cdc2 parents 2194f3d e8422d21 file · +3 −0Browse files

Unified · Split

packages/react/src/api/scope-context.tsx+3−0
@@ -41,6 +41,7 @@ export function ScopeProvider(props: React.PropsWithChildren<{ fallback?: React. · 40 unmodified lines
41export function useScope(): ScopeId {41export function useScope(): ScopeId {
42 const scope = React.useContext(ScopeContext);42 const scope = React.useContext(ScopeContext);
43 if (scope === null) {43 if (scope === null) {
44 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: React hook invariant
44 throw new Error("useScope must be used inside a ScopeProvider");45 throw new Error("useScope must be used inside a ScopeProvider");
45 }46 }
46 return scope.id;47 return scope.id;
@@ -53,6 +54,7 @@ export function useScope(): ScopeId { · 6 unmodified lines
53export function useScopeInfo(): ScopeInfo {54export function useScopeInfo(): ScopeInfo {
54 const scope = React.useContext(ScopeContext);55 const scope = React.useContext(ScopeContext);
55 if (scope === null) {56 if (scope === null) {
57 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: React hook invariant
56 throw new Error("useScopeInfo must be used inside a ScopeProvider");58 throw new Error("useScopeInfo must be used inside a ScopeProvider");
57 }59 }
58 return scope;60 return scope;
@@ -66,6 +68,7 @@ export function useUserScope(): ScopeId { · 7 unmodified lines
66 const stack = useScopeStack();68 const stack = useScopeStack();
67 const innermost = stack[0];69 const innermost = stack[0];
68 if (!innermost) {70 if (!innermost) {
71 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: React hook invariant
69 throw new Error("useUserScope requires a non-empty scope stack");72 throw new Error("useUserScope requires a non-empty scope stack");
70 }73 }
71 return innermost.id;74 return innermost.id;