Last active
October 15, 2024 13:54
-
-
Save mhsattarian/0462b222858f698eed7c8c8dbdeacc15 to your computer and use it in GitHub Desktop.
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 characters
| /** Determines value is not undefined or null. */ | |
| export const isValue = <T>(value: T | undefined | null): value is T => | |
| (value as T) !== undefined && (value as T) !== null; | |
| export function JoinElements(elements: ReactNode[]) { | |
| return elements.reduce((prev, curr) => | |
| !isValue(curr) ? prev : [prev, ', ', curr] | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment