question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React.createClass is not a function

See original GitHub issue

Hey,

When attempting to use Cleave.js with React, I’m getting the following error:

Cleave.react.js:12 Uncaught TypeError: React.createClass is not a function

I’m using it like instructed in the docs:

import Cleave from 'cleave.js/dist/cleave-react'

By the way, I didn’t want to use the uncompiled version because i don’t want to use stage-0 (as a side note - it doesn’t work even when I add stage-0 and use the regular uncompiled version i.e. import Cleave from 'cleave.js/react' - same error).

Looks like require('react') returns an empty object for some reason, but I couldn’t figure out why.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
giladgocommented, Sep 6, 2016

ok, I think I figured out what was going on: In my webpack.config.js, I had this:

modulesDirectories: ['.', /*more stuff */]

Which means that when cleave was doing require('react'), webpack thought it was trying to load react.js in cleave’s directory, instead of react itself.

I changed my config to

root: path.resolve('.')

and things work now.

Thanks! 😄

0reactions
giladgocommented, Sep 6, 2016

cleave.js v0.7.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJs CreateClass is not a function - Stack Overflow
createClass () for the components use the createReactClass() var. Example: Replace this: var TodoComponent = React.createClass({ render: function ...
Read more >
How to fix React createClass is not a function problem
Are you trying to use React.createClass? ... That's because this function does not exist in the newer version of React since the majority...
Read more >
Uncaught TypeError: React.createClass is not a function #1075
Not enough error to really help with this issue, but it doesn't seem related to React DevTools. I assume you're seeing this in...
Read more >
TypeError: React.createClass is not a function
I just dropped the interop example into a create-react-app reason script boilerplate and im getting “TypeError: React.createClass is not a ...
Read more >
I get this error: "_react2.default.createClass is not a function ...
In the video there are no Javascript errors, but I see this: Uncaught TypeError: react2.default.createClass is not a function at Object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found