Created
November 26, 2024 17:34
-
-
Save ruanvalente/e7b9af6ad1af5f51e3ed668dfa957cbc to your computer and use it in GitHub Desktop.
Revisions
-
ruanvalente created this gist
Nov 26, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ import React, { ReactNode } from 'react'; interface ConditionProps { when: boolean; children: ReactNode; else?: ReactNode; } export function Condition({ when, children, else: elseContent }: ConditionProps) { if (when) { return <>{children}</>; } return elseContent ? <>{elseContent}</> : null; }