uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.17k stars 156 forks source link

TypeError: Cannot read property 'warp' of null #51

Closed emindeniz99 closed 3 years ago

emindeniz99 commented 4 years ago
Uncaught TypeError: Cannot read property 'warp' of null
    at MDEditor._this.handleScroll (MDEditor.tsx:121)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at HTMLUnknownElement.sentryWrapped (helpers.ts:87)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)
    at executeDispatch (react-dom.development.js:389)
    at executeDispatchesInOrder (react-dom.development.js:414)
    at executeDispatchesAndRelease (react-dom.development.js:3278)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287)
    at forEachAccumulated (react-dom.development.js:3259)
    at runEventsInBatch (react-dom.development.js:3304)
    at runExtractedPluginEventsInBatch (react-dom.development.js:3514)
    at handleTopLevel (react-dom.development.js:3558)
    at batchedEventUpdates$1 (react-dom.development.js:21871)
    at batchedEventUpdates (react-dom.development.js:795)
    at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568)
    at attemptToDispatchEvent (react-dom.development.js:4267)
    at dispatchEvent (react-dom.development.js:4189)
    at unstable_runWithPriority (scheduler.development.js:653)
    at dispatchUserBlockingUpdate (react-dom.development.js:4172)
    at HTMLDocument.sentryWrapped (helpers.ts:87)
MDEditor._this.handleScroll
src/MDEditor.tsx:121
  118 | }
  119 | private handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
  120 |   const preview = this.preview.current!.mdp.current! as HTMLDivElement;
> 121 |   const textarea = this.textarea.current!.warp.current! as HTMLDivElement;
      | ^  122 |   if (textarea && preview) {
  123 |     const scale = (textarea.scrollHeight - textarea.offsetHeight) / (preview.scrollHeight - preview.offsetHeight);
  124 |     if (e.target === textarea && this.leftScroll) {
View compiled
HTMLUnknownElement.callCallback
node_modules/react-dom/cjs/react-dom.development.js:188
HTMLUnknownElement.sentryWrapped
src/helpers.ts:87
  84 | } else {
  85 |   // If config is not fetched yet, wait for all configs (we don't know which one we need) and
  86 |   // find the appId (if any) corresponding to this measurementId. If there is one, wait on
> 87 |   // that appId's initialization promise. If there is none, promise resolves and gtag
     | ^  88 |   // call goes through.
  89 |   const dynamicConfigResults = await Promise.all(dynamicConfigPromisesList);
  90 |   const foundConfig = dynamicConfigResults.find(
"@uiw/react-md-editor": "^1.14.4",

When I changed modes, preview, editor, both, This Type Error occured.

jaywcjlove commented 4 years ago

@emindeniz99 Upgrade + @uiw/react-md-editor@1.14.5