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
Nextjs13 serverside components #536
Comments
Even I came across the same error: Error [TypeError]: Super expression must either be null or a function. @nickgrato thanks for sharing the resolution as well. `null
|
I bumped into this issue again. Something like this should do the work if you import it in your server component. Only this small piece of code will be client side, minimizing the impact "use client"
import { Prism } from 'react-syntax-highlighter';
import { dark } from 'react-syntax-highlighter/dist/esm/styles/prism';
export function SyntaxHighlighter(children: React.ReactNode) {
return (
<Prism language="javascript" style={dark}>
{children}
</Prism>
); |
I ended up going with another library for now but will stay tuned here. |
Which library are you using? I was regarding this feature for my portfolio. |
Sorry for the late reply - I ended up using shiki - I did have to hack a little of that even to get that to work right though.... my blog's code should be public if you want to see how I did it. @barrett-ruth https://github.com/nickgrato/grato_codes/blob/main/app/blog/%5Bslug%5D/page.tsx |
Your blog looks cool! Can you explain why was it so tricky to implement? |
thank you! so in that link I sent you if you look at the function getHighlighter(); it shows the "ticky-ness" but even with shiki I had to tell nextjs about the library so on the serverside it has those files "return pathJoin(process.cwd(), 'libs/shiki');" and doesn't wait till the client side to access that library. |
I think there is a similar issue with the So, you handled it to be rendered in serverside, right? |
correct |
Describe the bug
When using in a Nextjs13 server component I get the error "Error [TypeError]: Super expression must either be null or a function". When I turn the component into a client-side component everything works fine. The dilemma is for me to have syntax highlighting I can't have a more performant serverside blog page but need to make it client-side. It would be awesome if this lib worked on server-side components.
To Reproduce
Steps to reproduce the behavior:
TEST
Expected behavior
"Error [TypeError]: Super expression must either be null or a function" error should be displayed.
Screenshots
I don't think screenshots would be helpful here.
Desktop (please complete the following information):
Additional context
This works great non-the-less. I know everyone is catching up to serverside stuff so understandable. This is a great product.
The text was updated successfully, but these errors were encountered: