Skip to content

Commit

Permalink
#369 Fix React.lazy contract (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky authored May 20, 2021
1 parent 5b793d2 commit 0964ef0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kotlin-react/src/main/kotlin/react/Imports.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ external fun <P : RProps> memo(fc: FunctionalComponent<P>): FunctionalComponent<
external fun <P : RProps> memo(fc: FunctionalComponent<P>, areEqual: (P, P) -> Boolean): FunctionalComponent<P>

// Lazy (16.6+)
external fun <P : RProps> lazy(loadComponent: () -> Promise<RClass<P>>): RClass<P>
external fun <P : RProps> lazy(
factory: () -> Promise<RClassModule<P>>
): RClass<P>

// Suspense (16.6+)
external interface SuspenseProps : RProps
Expand Down
4 changes: 4 additions & 0 deletions kotlin-react/src/main/kotlin/react/ReactComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ val RErrorInfo.componentStack: Any
// TODO: Should extend RComponentClassStatics, but has problems with generic params
external interface RClass<in P : RProps> : RComponentClassStatics<RProps, RState, RContext<Any>?>

external interface RClassModule<in P : RProps> {
val default: RClass<P>
}

external interface RComponentClassStatics<P : RProps, S : RState, C : RContext<Any>?> {
var displayName: String?

Expand Down

0 comments on commit 0964ef0

Please sign in to comment.