ismaelga / react-json-editor

A dynamic form component for react using JSON-Schema.
https://ismaelga.github.io/react-json-editor
MIT License
225 stars 42 forks source link

React.createClass is not a function #37

Open maixing opened 6 years ago

maixing commented 6 years ago

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

olgn commented 6 years ago

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...

mrovinsky commented 6 years ago

Is there a planned update to solve the issue?

jcdiprose commented 5 years ago

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