Skip to content

Commit

Permalink
extracted SuspenderProps interface for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
01abhay committed Mar 1, 2024
1 parent 434bd9f commit 34d38d6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ import React, { Suspense, Fragment } from "react";

const infiniteThenable = { then() {} };

function Suspender({
freeze,
children,
}: {
interface SuspenderProps {
freeze: boolean;
children: React.ReactNode;
}) {
}

function Suspender({ freeze, children }: SuspenderProps) {
if (freeze) {
throw infiniteThenable;
}
return <Fragment>{children}</Fragment>;
}

interface Props {
freeze: boolean;
children: React.ReactNode;
interface FreezeProps extends SuspenderProps {
placeholder?: React.ReactNode;
}

export function Freeze({ freeze, children, placeholder = null }: Props) {
export function Freeze({ freeze, children, placeholder = null }: FreezeProps) {
return (
<Suspense fallback={placeholder}>
<Suspender freeze={freeze}>{children}</Suspender>
Expand Down

0 comments on commit 34d38d6

Please sign in to comment.