Files
bun.sh/test/snippets/react-context-value-func.tsx
Don Isaac 81ecf7556c ci: repair lint setup and run it in CI (#15720)
Co-authored-by: Don Isaac <don@bun.sh>
2025-01-08 07:12:18 +00:00

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);
}