Skip to content

🐛 Bug: React rendering crash in StyledMarkdownBlock for single-child table headers #2256

@h30s

Description

@h30s

Describe the bug

There is a logic flaw in the checkHasContent utility function (lib/markdownUtils.ts) that causes a complete page crash when a Markdown table header has exactly one column.

The function assumes reactNode.props.children is an array and calls .reduce() on it. However, if a component only has one child in React, props.children is an object, not an array. When markdown-to-jsx renders a single-column table, props.children on the <tr> wrapper is a single <th> object. Calling .reduce() on this object throws TypeError: reactNode.props.children.reduce is not a function, crashing the entire page render.

Steps To Reproduce

  1. Create or edit a markdown file rendered via StyledMarkdownBlock.
  2. Add a table with only one column:
  3. Load the page locally or in preview.
  4. See the TypeError complete page crash in the browser console / terminal.

Expected Behavior

The page should render the single-column table correctly without crashing. The utility function should safely iterate React children using React.Children.toArray() or check Array.isArray() before assuming array methods are available.

Screenshots

No response

Device Information [optional]

- OS:
- Browser:
- version:

Are you working on this issue?

Yes

Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)

Yes

Metadata

Metadata

Assignees

Labels

Status: TriageThis is the initial status for an issue that requires triage.🐛 BugIndicates that the issue is a bug or defect.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions