Created
March 17, 2022 13:41
-
-
Save sproctor/3a28491075723b54dedd4f5a1e0ae302 to your computer and use it in GitHub Desktop.
use-error-boundary bindings for kotlin/js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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