diff --git a/src/components/InjectedComponents/AddToKeyStore.tsx b/src/components/InjectedComponents/AddToKeyStore.tsx index 2582cd21b928..39e9f9ebf21c 100644 --- a/src/components/InjectedComponents/AddToKeyStore.tsx +++ b/src/components/InjectedComponents/AddToKeyStore.tsx @@ -9,7 +9,7 @@ export interface AddToKeyStoreProps { provePost: string postBy: ProfileIdentifier completeComponentProps?: Partial - completeComponent?: React.ComponentType + completeComponent?: React.ComponentType<{ data: boolean }> waitingComponentProps?: Partial waitingComponent?: React.ComponentType failedComponentProps?: Partial diff --git a/src/components/InjectedComponents/DecryptedPost.tsx b/src/components/InjectedComponents/DecryptedPost.tsx index be454b581411..61f4fbb7a800 100644 --- a/src/components/InjectedComponents/DecryptedPost.tsx +++ b/src/components/InjectedComponents/DecryptedPost.tsx @@ -112,7 +112,7 @@ export const DecryptPostFailed = React.memo(function DecryptPostFailed({ error, return ( ) diff --git a/src/utils/components/AsyncComponent.tsx b/src/utils/components/AsyncComponent.tsx index d3c5c875cf88..83afe95795f5 100644 --- a/src/utils/components/AsyncComponent.tsx +++ b/src/utils/components/AsyncComponent.tsx @@ -8,9 +8,9 @@ type PromiseState = export default function AsyncComponent(props: { promise: () => Promise dependencies: ReadonlyArray - completeComponent: React.ComponentType<{ data: Return }> | React.ReactNode + completeComponent: React.ComponentType<{ data: Return }> awaitingComponent: React.SuspenseProps['fallback'] - failedComponent: React.ComponentType<{ error: Error }> | React.ReactNode + failedComponent: React.ComponentType<{ error: Error }> | null }) { const [state, setState] = React.useState>({ status: 'not-started' }) // eslint-disable-next-line @@ -30,16 +30,15 @@ export default function AsyncComponent(props: { return { default: () => { const CompleteComponent = props.completeComponent - if (isComponent(CompleteComponent)) return - else return (CompleteComponent as React.ReactElement) || null + return }, } } catch (e) { return { default: () => { const FailedComponent = props.failedComponent - if (isComponent(FailedComponent)) return - else return (FailedComponent as React.ReactElement) || null + if (FailedComponent === null) return null + return }, } } @@ -54,10 +53,6 @@ export default function AsyncComponent(props: { ) } -function isComponent(f?: React.ComponentType | NonNullable | null): f is React.ComponentType { - return typeof f === 'function' -} - /** React hook for not-cancelable async calculation */ export function useAsync(fn: () => PromiseLike, dep: ReadonlyArray): PromiseLike { let res: Parameters[0]>[0] = () => {}, diff --git a/src/utils/jss/renderInShadowRoot.tsx b/src/utils/jss/renderInShadowRoot.tsx index b59985d13092..eec88a3d088f 100644 --- a/src/utils/jss/renderInShadowRoot.tsx +++ b/src/utils/jss/renderInShadowRoot.tsx @@ -30,7 +30,7 @@ const generateClassName = createGenerateClassName() export class RenderInShadowRootWrapper extends React.PureComponent { state: { error?: Error } = { error: undefined } render() { - if (this.state.error) return this.state.error.message + if (this.state.error) return
{this.state.error.message}
return } componentDidCatch(error: Error) {