From 5ccfc42e06d69e5671e6d2feac630f1672a8e3d3 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Mon, 11 Jan 2021 19:25:30 -0500 Subject: [PATCH] Add LineBreakToBrTag component --- src/components/LineBreakToBrTag.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/components/LineBreakToBrTag.tsx diff --git a/src/components/LineBreakToBrTag.tsx b/src/components/LineBreakToBrTag.tsx new file mode 100644 index 0000000..5aa20b5 --- /dev/null +++ b/src/components/LineBreakToBrTag.tsx @@ -0,0 +1,13 @@ +export default function LinebreakToBrTag({ text }: { text: string }) { + // Must be wrapped in fragment to process react nodes correctly + return ( + <> + {text.split('\n').map((line) => ( + <> + {line} +
+ + ))} + + ); +}