mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
36 lines
679 B
TypeScript
36 lines
679 B
TypeScript
// @ts-nocheck
|
|
import React from "react";
|
|
|
|
const Context = React.createContext({});
|
|
|
|
const ContextProvider = ({ children }) => {
|
|
const [cb, setCB] = React.useState(function () {});
|
|
const foo = true;
|
|
|
|
return <Context.Provider value={cb}>{children(foo)}</Context.Provider>;
|
|
};
|
|
|
|
const ContextValue = () => (
|
|
<Context.Consumer>
|
|
{foo => {
|
|
if (foo) {
|
|
return <div>Worked!</div>;
|
|
}
|
|
|
|
throw `Value "${foo}"" should be true`;
|
|
}}
|
|
</Context.Consumer>
|
|
);
|
|
|
|
const TestComponent = () => (
|
|
<ContextProvider>
|
|
<ContextValue />
|
|
</ContextProvider>
|
|
);
|
|
|
|
export function test() {
|
|
const foo = <TestComponent />;
|
|
|
|
return testDone(import.meta.url);
|
|
}
|