Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _react2.default.createClass is not a function #110

Closed
aranand2006 opened this issue Dec 5, 2017 · 6 comments
Closed

TypeError: _react2.default.createClass is not a function #110

aranand2006 opened this issue Dec 5, 2017 · 6 comments

Comments

@aranand2006
Copy link

./node_modules/react-formio/lib/components/FormComponents/address.js
node_modules/react-formio/lib/components/FormComponents/address.js:25

22 |
23 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 |

25 | module.exports = _react2.default.createClass({
26 | displayName: 'Address',
27 | mixins: [_valueMixin2.default, _selectMixin2.default, _componentMixin2.default],
28 | getTextField: function getTextField() {

@harrowm
Copy link

harrowm commented Jan 5, 2018

The code needs to be changed for React v16 .. the create class has moved to a separate require.

EDIT: spotting the error is much easier than correcting it ! I did a clone and took a look at the code. The files that need changing on my installation are in

node_modules/react-formio/lib/components/FormComponents/

e.g. button.js: the line

module.exports = _react2.default.createClass({

needs to change to

var createReactClass = require('create-react-class')
module.exports = createReactClass({

or similar. The trouble is when I clone the code, the lib directory doesn't contain these files. Can anyone explain ?

Malcolm

@ghost
Copy link

ghost commented Jan 16, 2018

@harrowm That's because the lib folder that you get when you npm install --save formio-react is already a built version (transpiled to ES5 by Babel). So the babel plugin or preset needs to be updated and not necessarily the source code you have on this repo.

@prycec
Copy link

prycec commented Jan 25, 2018

What is the status of this issue?

@chamindasion
Copy link

This is due to react version 16 not supporting for createclass. I could overcome by downgrading react and reactdom to version 15. Basically update you package.json file for react and reactdom to version 15. And run npm install again

@bionicvapourboy
Copy link

Downgrade is not an option because in my app I make use of fragments, portals and so on.

@randallknutson
Copy link
Contributor

Use react-formio v2.0 or higher which supports react 16. The react-formio v1.x uses createClass extensively which won't work in react 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants