/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/docusaurus-theme-live-codeblock/src/client/context.tsx
36 строк
870 B
Neel Bansal
feat(theme-live-codeblock): reset button + wire `position` prop (#11675)
19 фев 2026, 19:41
Не верифицирован
19 фев 2026, 19:41
49619fd
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import {createContext, useContext, type ReactNode} from 'react'; type PlaygroundContextValue = { reset: () => void; }; const PlaygroundContext = createContext<PlaygroundContextValue | null>(null); export function PlaygroundProvider({ value, children, }: { value: PlaygroundContextValue; children: ReactNode; }): ReactNode { return ( <PlaygroundContext.Provider value={value}> {children} </PlaygroundContext.Provider> ); } export function usePlayground(): PlaygroundContextValue { const context = useContext(PlaygroundContext); if (!context) { throw new Error('usePlayground must be used within PlaygroundProvider'); } return context; }