TypeError when running MDEditor in NextJS
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 201
- Avg merge
- 12m
- Merged PRs (30d)
- 1
Description
I am running v3.20.1 of react-md-editor, in NextJS v13.0.7, trying to use the MDEditor with react-hook-forms under a controlled input. It works well, except for the fact that every other page load or so, I get this error:
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'source')
Call Stack
source
node_modules/rehype-prism-plus/node_modules/refractor/lang/js-templates.js (12:56)
Prism
node_modules/rehype-prism-plus/node_modules/refractor/lang/js-templates.js (375:5)
syntax
node_modules/rehype-prism-plus/node_modules/refractor/lib/core.js (125:4)
refractor
node_modules/rehype-prism-plus/node_modules/refractor/lib/all.js (454:0)
./node_modules/rehype-prism-plus/node_modules/refractor/lib/all.js
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/node_modules_uiw_react-md-editor_esm_index_js.js (5338:1)
options.factory
/_next/static/chunks/webpack.js (713:31)
__webpack_require__
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (368:21)
eval
webpack-internal:///./node_modules/rehype-prism-plus/dist/rehype-prism-plus.es.js (12:78)
./node_modules/rehype-prism-plus/dist/rehype-prism-plus.es.js
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/node_modules_uiw_react-md-editor_esm_index_js.js (1978:1)
options.factory
/_next/static/chunks/webpack.js (713:31)
__webpack_require__
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (368:21)
eval
webpack-internal:///./node_modules/@uiw/react-markdown-preview/esm/index.js (13:75)
./node_modules/@uiw/react-markdown-preview/esm/index.js
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/node_modules_uiw_react-md-editor_esm_index_js.js (28:1)
options.factory
/_next/static/chunks/webpack.js (713:31)
__webpack_require__
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (368:21)
eval
webpack-internal:///./node_modules/@uiw/react-md-editor/esm/Editor.js (6:85)
./node_modules/@uiw/react-md-editor/esm/Editor.js
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/node_modules_uiw_react-md-editor_esm_index_js.js (94:1)
options.factory
/_next/static/chunks/webpack.js (713:31)
__webpack_require__
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (368:21)
eval
webpack-internal:///./node_modules/@uiw/react-md-editor/esm/index.js (6:65)
./node_modules/@uiw/react-md-editor/esm/index.js
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/node_modules_uiw_react-md-editor_esm_index_js.js (435:1)
options.factory
/_next/static/chunks/webpack.js (713:31)
__webpack_require__
file:///Users/zachm/Desktop/dev/zachoverflow/.next/static/chunks/webpack.js (37:33)
Function.fn
/_next/static/chunks/webpack.js (368:21)
I am fine with ignoring it, as it is not every single time, but I am not sure why the error is happening. Can anyone assist?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MDEditor and Editor entry points shown in the stack trace, then inspect the rehype-prism-plus and refractor paths around js-templates.js. Reproduce the intermittent NextJS v13.0.7 failure with react-hook-form and verify that page loads no longer raise the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100