Reputation: 30298
The following is giving me an error in React v16.0. The error I'm getting is:
TypeError: Cannot read property 'createElement' of undefined
import { React, Component } from 'react';
class MyComponent extends Component {
render() {
return(
<div>Hello World!</div>
);
};
};
If I change it to the following, it works.
import React from 'react';
class MyComponent extends React.Component {
// Omitted for brevity
}
I'm aware of some changes from v15.x to 16.x but I'm not clear about this one.
Upvotes: 0
Views: 36
Reputation: 3392
Your import needs to be the following: import React, { Component } from 'react';
React
is your standard default export as before but Component
is a named export.
Upvotes: 2