I am trying to figure out how to respond to the warning in react to use javascript classes to create components in my MERN app.
The warning says:
Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see[ \[this link\][1]
The link in that message says:
// After (15.5)
var React = require('react');
var createReactClass = require('create-react-class');
var Component = createReactClass({
mixins: [MixinA],
render() {
return <Child />;
}
});
I am using react v 15.5.4
In my app, I have tried to change my components as follows:
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from 'react-bootstrap';
var createReactClass = require('create-react-class');
var GreeterForm = createReactClass({
onFormSubmit: function(e) {
e.preventDefault();
However, the warning persists. Can anyone see what I have done wrong? How do I implement the new approach to defining components?
react-bootstrapmight still be usingReact.createClassor you have another component somewhere that uses it? But why not useclassas suggested in the warning?