Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJulian Valencia
10,492 PointsI get this error: "_react2.default.createClass is not a function" and React.PropTypes is undefined
In the video there are no Javascript errors, but I see this:
Uncaught TypeError: react2.default.createClass is not a function at Object.<anonymous> (bundle.js:986) at __webpack_require_ (bundle.js:20) at module.exports (bundle.js:63) at bundle.js:66
Also, the React.PropTypes used in the project files is no longer working
2 Answers
Julian Valencia
10,492 PointsOk, I found the solution!
Due to updates on the latest versions of React, in order to use Create Class you'll need to import an additional package:
sudo npm install create-react-class --save
And then change the way you do the Create Class like this:
var createReactClass = require('create-react-class');
const Scoreboard = createReactClass({ ...
Note that PropTypes also changed, it has been moved to an external package so in order to use PropTypes you'll need to import the package:
sudo npm install prop-types --save
And then reference the PropTypes like this:
Import the package:
import PropTypes from 'prop-types';
Header.propTypes = {
players: PropTypes.array.isRequired,
};
;```
John Potts
978 PointsThank you, worked perfectly!
Quentin Olivier
4,124 PointsHello !
I have same problem, "Uncaught TypeError: _react2.default.createReactClass is not a function".
I followed the configuration videos, and I try your answer, but I still have the problem.
I am at this video : https://teamtreehouse.com/library/hot-reloading-your-react-app
Best regards,
Kyree S. Williams
1,713 PointsI had the same issue, too. Make sure you remove the React
prefix from these statements, since---as Julian said---they are no longer part of React, but are separate packages.
So instead of React.createClass({...
, you'll have createReactClass({...
. Likewise, instead of React.PropTypes.array.isRequired
, you would have just PropTypes.array.isRequired
. Just get rid of the React prefix.
Ari Misha
19,323 PointsAri Misha
19,323 PointsHiya there! Can you post your whole code here? (: