Skip to content

Using ReactNode as child of <Code> breaks the component #27

@alfonsusac

Description

@alfonsusac

Usage:

<Code>
  <div>asd</div>
</Code>

Tested in Next.js 13.4.14 Server Component

Errors:

- error TypeError: Cannot read properties of undefined (reading 'children')
    at eval (../bright/lib/src/index.tsx:179:53)
    at Array.map (<anonymous>)
    at parseChildren (../bright/lib/src/index.tsx:176:88)
    at Code (../bright/lib/src/index.tsx:34:31)
    at stringify (<anonymous>)
digest: "1512087678"
  203 |       const codeProps = c.props?.children?.props
  204 |       return {
> 205 |         code: trimTrailingNewline(codeProps.children),
      |                                            ^
  206 |         ...getLanguageAndTitle(codeProps.className),
  207 |       }
  208 |     })

this error is using bright/src not bright/dist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions