Skip to content

Instantly share code, notes, and snippets.

@sproctor
Created March 17, 2022 13:41
Show Gist options
  • Save sproctor/3a28491075723b54dedd4f5a1e0ae302 to your computer and use it in GitHub Desktop.
Save sproctor/3a28491075723b54dedd4f5a1e0ae302 to your computer and use it in GitHub Desktop.
use-error-boundary bindings for kotlin/js
@file:JsModule("use-error-boundary")
@file:JsNonModule
package externals
import react.*
external interface ErrorState {
var didCatch: Boolean?
var error: Any?
}
external interface UseErrorBoundaryState : ErrorState {
var ErrorBoundary: FC<ErrorBoundaryWrapperProps>
var reset: () -> Unit
}
external interface UseErrorBoundaryOptions {
var onDidCatch: ((error: Any, errorInfo: Any) -> Unit)?
}
@JsName("useErrorBoundary")
external fun useErrorBoundary(options: UseErrorBoundaryOptions?): UseErrorBoundaryState
external interface ErrorObject {
var error: Any
}
external interface ErrorBoundaryWrapperProps : PropsWithChildren {
var render: (() -> react.ReactNode)?
var renderError: ((error: ErrorObject) -> react.ReactNode)?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment