createVersionedContext()
Home > @backstage/version-bridge
> createVersionedContext
Get the existing or create a new versioned React context that's stored inside a global singleton.
Signature:
function createVersionedContext<Versions extends {
[version in number]: unknown;
}>(key: string): Context<VersionedValue<Versions> | undefined>;
Parameters
Parameter |
Type |
Description |
---|---|---|
key |
string |
A key that uniquely identifies the context. |
Context<VersionedValue<Versions> | undefined>
Example
const MyContext = createVersionedContext<{ 1: string }>('my-context');
const MyContextProvider = ({children}) => (
<MyContext.Provider value={createVersionedValueMap({ 1: 'value-for-version-1' })}>
{children}
<MyContext.Provider>
)