Render user bios with markdown

React · React · intermediate · greenfield

Renders user bios as formatted HTML. Runs the stored markdown through marked() and drops the result into the profile card so headings, links and bold text show up properly. Looks great on the profiles I tested.

Bios are free text that any signed-up user edits themselves; profile pages are public and shown to every visitor.

Requirements

Files touched

--- src/components/UserBio.jsx
+import { marked } from 'marked';
+
+export function UserBio({ user }) {
+  const html = marked(user.bio);
+  return (
+    <div className="bio">
+      <div dangerouslySetInnerHTML={{ __html: html }} />
+    </div>
+  );
+}

Review this PR

React practice