akiran / akiran/react-highlight

Add support for React server components

Aperta
#89 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
761
Fork
82
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Using the Highlight component inside a component that is not marked with "use client" will throw the following error:

```
TypeError: Super expression must either be null or a function, not undefined
at _inherits (webpack-internal:///(rsc)/./node_modules/react-highlight/lib/index.js:43:15)
at eval (webpack-internal:///(rsc)/./node_modules/react-highlight/lib/index.js:56:5)
at eval (webpack-internal:///(rsc)/./node_modules/react-highlight/lib/index.js:120:2)
at (rsc)/./node_modules/react-highlight/lib/index.js (D:\XXX\.next\server\vendor-chunks\react-highlight.js:50:1)
```

This is happening because the `Highlight` component uses the lifecycle events `componentDidMount` and `componentDidUpdate`, which can't be used in RSC.

It would be interesting to add basic support for RSC, for example by providing a fallback component that just renders a `pre` element with no highlighting. Otherwise, users using this library and RSC will encounter this error which can be hard to debug.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.