I am getting this error and don't know what's wrong, my code is simple I'm just trying to push an array. Is so basic but yet can't figure it out.
I'm using Meteor 1.5.3 with React 16
import React, { Component, PropTypes } from 'react';
export default class ListMeds extends Component {
render(){
return(
<li>{this.props.meds.text}</li>
);
}
}
ListMeds.propTypes = {
meds: React.PropTypes.object.isRequired,
};
This error appears because of you use the 16th version of React.js. In this blog post (announce of React.js version 16) you can read:
The deprecations introduced in 15.x have been removed from the core package. React.createClass is now available as create-react-class, React.PropTypes as prop-types...
You should install prop-types module with (if you use npm
):
npm install --save prop-types
or
yarn add prop-types
for yarn
case. And rewrite your code this way:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class ListMeds extends Component {
render(){
return(
<li>{this.props.meds.text}</li>
);
}
}
ListMeds.propTypes = {
meds: PropTypes.object.isRequired,
};