3 Commits

Author SHA1 Message Date
Julien Valverdé
b50255ded2 Merge branch 'queryclient' of git.valverde.cloud:Thilawyn/reffuse into queryclient
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-26 19:34:59 +01:00
Julien Valverdé
03f0b623ed Removed JSX code 2025-03-26 19:34:21 +01:00
Julien Valverdé
fb6d803723 Removed JSX code 2025-03-26 19:34:14 +01:00
3 changed files with 19 additions and 36 deletions

View File

@@ -36,12 +36,7 @@ function makeProvider<R>(Context: React.Context<Context.Context<R>>): ReactProvi
Runtime.runSync(runtime),
), [props.layer, runtime])
return (
<Context
{...props}
value={value}
/>
)
return React.createElement(Context, { ...props, value })
}
}
@@ -57,13 +52,7 @@ function makeAsyncProvider<R>(Context: React.Context<Context.Context<R>>): Async
readonly children?: React.ReactNode
}) {
const value = React.use(promise)
return (
<Context
value={value}
children={children}
/>
)
return React.createElement(Context, { value, children })
}
return function ReffuseContextAsyncReactProvider(props) {
@@ -74,14 +63,8 @@ function makeAsyncProvider<R>(Context: React.Context<Context.Context<R>>): Async
Runtime.runPromise(runtime),
), [props.layer, runtime])
return (
<React.Suspense fallback={props.fallback}>
<Inner
{...props}
promise={promise}
/>
</React.Suspense>
)
const inner = React.createElement(Inner, { ...props, promise })
return React.createElement(React.Suspense, { children: inner, fallback: props.fallback })
}
}

View File

@@ -0,0 +1,15 @@
import { Runtime } from "effect"
import * as React from "react"
export const Context = React.createContext<Runtime.Runtime<never>>(null!)
export const Provider = (props: {
readonly children?: React.ReactNode
}) => React.createElement(Context, {
...props,
value: Runtime.defaultRuntime,
})
Provider.displayName = "ReffuseRuntimeReactProvider" as const
export const useRuntime = () => React.useContext(Context)

View File

@@ -1,15 +0,0 @@
import { Runtime } from "effect"
import * as React from "react"
export const Context = React.createContext<Runtime.Runtime<never>>(null!)
export const Provider = (props: { readonly children?: React.ReactNode }) => (
<Context
{...props}
value={Runtime.defaultRuntime}
/>
)
Provider.displayName = "ReffuseRuntimeReactProvider"
export const useRuntime = () => React.useContext(Context)