0.1.2 #3
@@ -328,29 +328,6 @@ export const withOptions: {
|
||||
Object.getPrototypeOf(self),
|
||||
))
|
||||
|
||||
export const withRuntime: {
|
||||
<T extends Component<any, R, any>, R>(
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): (self: T) => React.FC<T extends Suspense
|
||||
? Component.Props<T> & SuspenseProps
|
||||
: Component.Props<T>
|
||||
>
|
||||
<E, R, P extends {}>(
|
||||
self: Component<E, R, P> & Suspense,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P & SuspenseProps>
|
||||
<E, R, P extends {}>(
|
||||
self: Component<E, R, P>,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P>
|
||||
} = Function.dual(2, <E, R, P extends {}>(
|
||||
self: Component<E, R, P>,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P> => function WithRuntime(props) {
|
||||
const runtime = React.useContext(context)
|
||||
return React.createElement(Runtime.runSync(runtime)(useFC(self)), props)
|
||||
})
|
||||
|
||||
|
||||
export interface Memoized<P> {
|
||||
readonly memo: true
|
||||
@@ -403,6 +380,29 @@ export const suspense = <T extends Component<any, any, P>, P extends {}>(
|
||||
)
|
||||
|
||||
|
||||
export const withRuntime: {
|
||||
<T extends Component<any, R, any>, R>(
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): (self: T) => React.FC<T extends Suspense
|
||||
? Component.Props<T> & SuspenseProps
|
||||
: Component.Props<T>
|
||||
>
|
||||
<E, R, P extends {}>(
|
||||
self: Component<E, R, P> & Suspense,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P & SuspenseProps>
|
||||
<E, R, P extends {}>(
|
||||
self: Component<E, R, P>,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P>
|
||||
} = Function.dual(2, <E, R, P extends {}>(
|
||||
self: Component<E, R, P>,
|
||||
context: React.Context<Runtime.Runtime<R>>,
|
||||
): React.FC<P> => function WithRuntime(props) {
|
||||
const runtime = React.useContext(context)
|
||||
return React.createElement(Runtime.runSync(runtime)(useFC(self)), props)
|
||||
})
|
||||
|
||||
export const useFC: {
|
||||
<E, R, P extends {}>(
|
||||
self: Component<E, R, P> & Suspense
|
||||
|
||||
Reference in New Issue
Block a user