Git Product home page Git Product logo

Comments (4)

sstur avatar sstur commented on September 24, 2024

That's so weird. Nothing in react-rte or draft-js uses jQuery. Do you have a stack trace to go with that error?

Weirdly still, the TypeError says cannot find property 'jquery' yet the line is asking for jQuery (case difference).

I wonder if this could be related to jsdom which I'm using in my tests. You could try setting global.window = global and see if that makes the error disappear, since the actual error is not related to jQuery or Zepto but the fact that window is undefined.

from react-rte.

ZeroCho avatar ZeroCho commented on September 24, 2024

Oops. It was jQuery not jquery. I changed it.
I have a stack trace but it is useless because it shows the result after being webpacked.
like the following

TypeError: Cannot read property 'jQuery' of undefined
    at C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:38109:29
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:38124:5)
    at Object.module.exports.module.exports.module.deprecate (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:38125:32)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.module.exports._typeof (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:37368:18)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:37115:23)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:37015:19)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.module.exports._typeof (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:36804:29)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.module.exports._typeof (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:36564:25)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.module.exports._typeof (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:36281:26)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.module.exports.module.exports.BOLD.fontWeight (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:32672:29)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:31322:21)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30974:18)
    at __webpack_require__ (C:\Users\ZeroCho\WebstormProjects\zerocho-home\public\server.js:30934:31)

but as I followed the stack trace,

it shows DraftJS -> DraftEditor -> DraftEditorContents -> DraftEditorBlock -> DraftEditorLeaf -> DraftEditorTextNode -> UserAgent -> UserAgentData -> UAParser
then some codes like this
(typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' ? window : undefined)

I checked all above dependencies and none of them use jquery except UAParser,
It's a problem in ua-parser-js but this stops server-side-rendering
ua-parser-js link 869~END
By the way, where should I put global.window = global? In the server file?

from react-rte.

sstur avatar sstur commented on September 24, 2024

I was thinking you could try putting global.window = global; somewhere early in your loading chain. Maybe in your main file before you call your first require/import. It's just a guess really, I have no idea if it will fix anything.

from react-rte.

ZeroCho avatar ZeroCho commented on September 24, 2024

Finally solved by not using react-rte on server-side-rendering
I wrapped import codes with if (process.env.BROWSER) and made it rendered only if it is in browser environment. Then everything is fine
Still mysterious why this problem happens

from react-rte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.