akiran / akiran/react-highlight

Add support for React server components

Đang mở
#89 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
761
Fork
82
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.