mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Merge remote-tracking branch 'origin/dev' into devin/1780085594-readme-logo-background
This commit is contained in:
commit
236b1fe13e
@ -568,3 +568,6 @@ A: Microsoft Entra ID's v2 token endpoint can reject authorization-code exchange
|
||||
|
||||
## Q: How should the development-environment dashboard load local config files?
|
||||
A: Use `jiti` to import the user's config module, matching `stack config push`, so helper functions such as `defineStackConfig(...)` or `makeConfig()` work. Disable `moduleCache` for this reader because the development-environment file watcher may import the same config path repeatedly after edits, and cached modules would otherwise hide changes.
|
||||
|
||||
## Q: How should template React contexts avoid duplicate client-bundle context identities?
|
||||
A: Define exported provider contexts such as `StackContext` and `TranslationContext` through `createGlobal` from `@stackframe/stack-shared/dist/utils/globals`, not direct `React.createContext(...)` exports. That helper stores the React context under `globalThis[Symbol.for("__hexclave-globals")]`, so duplicated SDK bundles still share the same provider/consumer context object.
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { createGlobal } from "@stackframe/stack-shared/dist/utils/globals";
|
||||
import type { StackClientApp } from "../lib/stack-app/apps/interfaces/client-app";
|
||||
|
||||
export const StackContext = React.createContext<null | {
|
||||
type StackContextValue = {
|
||||
app: StackClientApp<true>,
|
||||
}>(null);
|
||||
};
|
||||
|
||||
export const StackContext = createGlobal<React.Context<StackContextValue | null>>(
|
||||
"StackContext",
|
||||
() => React.createContext<StackContextValue | null>(null),
|
||||
);
|
||||
StackContext.displayName ??= "StackContext";
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext } from "react";
|
||||
import React from "react";
|
||||
import { createGlobal } from "@stackframe/stack-shared/dist/utils/globals";
|
||||
|
||||
export const TranslationContext = createContext<null | {
|
||||
type TranslationContextValue = {
|
||||
quetzalKeys: Map<string, string>,
|
||||
quetzalLocale: Map<string, string>,
|
||||
}>(null);
|
||||
};
|
||||
|
||||
export const TranslationContext = createGlobal<React.Context<TranslationContextValue | null>>(
|
||||
"TranslationContext",
|
||||
() => React.createContext<TranslationContextValue | null>(null),
|
||||
);
|
||||
TranslationContext.displayName ??= "TranslationContext";
|
||||
|
||||
export function TranslationProviderClient(props: {
|
||||
children: React.ReactNode,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user