diff options
author | 2021-10-06 19:21:26 -0700 | |
---|---|---|
committer | 2021-10-06 19:21:26 -0700 | |
commit | a493c18193c4259efe272e4896187c562fd414b1 (patch) | |
tree | 9e0b1e73872559ee9ae7a26dffc823cca5a2c3f4 /integration/snippets/react-context-value-func.tsx | |
parent | 5370ea71c0b3a6759c481f96608ce855bd043bc8 (diff) | |
download | bun-a493c18193c4259efe272e4896187c562fd414b1.tar.gz bun-a493c18193c4259efe272e4896187c562fd414b1.tar.zst bun-a493c18193c4259efe272e4896187c562fd414b1.zip |
Fix JSX transform edgecase with static children
Diffstat (limited to 'integration/snippets/react-context-value-func.tsx')
-rw-r--r-- | integration/snippets/react-context-value-func.tsx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/integration/snippets/react-context-value-func.tsx b/integration/snippets/react-context-value-func.tsx new file mode 100644 index 000000000..5f38a5d1c --- /dev/null +++ b/integration/snippets/react-context-value-func.tsx @@ -0,0 +1,34 @@ +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); +} |