Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alfonsusac opened this issue Aug 14, 2023 · 1 comment
Open

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

alfonsusac opened this issue Aug 14, 2023 · 1 comment

Comments

@alfonsusac
Copy link

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

@alfonsusac
Copy link
Author

Im curioust to know, what this part of the code is meant to be used for?

} else if (typeof children === "object") {

I know the first guard is for Markdown, and the third one is for plain texts but what is the second one for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant