react-json-editor icon indicating copy to clipboard operation
react-json-editor copied to clipboard

React.createClass is not a function

Open maixing opened this issue 8 years ago • 3 comments

in React16 react-json-editor.js:436 Uncaught (in promise) TypeError: React.createClass is not a function at Object. (react-json-editor.js:436) at webpack_require (react-json-editor.js:30) at Object. (react-json-editor.js:417) at webpack_require (react-json-editor.js:30) at Object.module.exports (react-json-editor.js:97) at webpack_require (react-json-editor.js:30) at Object. (react-json-editor.js:83) at webpack_require (react-json-editor.js:30) at react-json-editor.js:50 at react-json-editor.js:53

maixing avatar Oct 22 '17 04:10 maixing

This is a pretty common issue when using packages that aren't updated for React 16. React took out the createClass function in version 16. You can get the code to work using the following workaround with the create-react-class package (yarn add create-react-class or npm install create-react-class - depending on your package manager):

import React from 'react' React.createClass = require('create-react-class') const Form = require('react-json-editor') ... do your thing here...

olgn avatar Jan 25 '18 20:01 olgn

Is there a planned update to solve the issue?

mrovinsky avatar May 29 '18 18:05 mrovinsky

Make a pull request importing create-react-class @mrovinsky and it might solve the issue.

jcdiprose avatar Mar 14 '19 17:03 jcdiprose