React.createClass is not a function
See original GitHub issueHey,
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:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok, I think I figured out what was going on: In my
webpack.config.js
, I had this:Which means that when cleave was doing
require('react')
, webpack thought it was trying to loadreact.js
in cleave’s directory, instead ofreact
itself.I changed my config to
and things work now.
Thanks! 😄
cleave.js
v0.7.3