Skip to content

Instantly share code, notes, and snippets.

@mhsattarian
Last active October 15, 2024 13:54
Show Gist options
  • Select an option

  • Save mhsattarian/0462b222858f698eed7c8c8dbdeacc15 to your computer and use it in GitHub Desktop.

Select an option

Save mhsattarian/0462b222858f698eed7c8c8dbdeacc15 to your computer and use it in GitHub Desktop.
/** 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