I have refactored the following component to ES6 and I am using the latest version of BabelJS. When I run webpack everything compiles with no issues the problems is I am getting the following error in the console In
Firefox 42.0 i get the following Error
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial
[[Prototype]] value using Object.create bundle.js:19697:416
TypeError: _react2.default.propTypes is undefined
In Google Chrome the following error is
Uncaught TypeError: Cannot read property 'string' of undefined
Here is the following component I am not sure what I am missing or what I have done wrong. I have been troubleshooting this for the last few days now.
import React from "react";
var $ = require('jquery');
class ChatList extends React.Component{
getInitialState(){
return{
chat:[]
}
}
getChats (){
$ajax({
url: this.props.URL,
type:'GET',
beforeSend: function(request){
request.setRequestHeader("X-Parse-Application-Id","AppID");
request.setRequestHeader("X-Parse-REST-API-Key","AppKEY");
request.setRequestHeader("Content-Type","application/json");
},
error: function(data){
console.log('There was an error in getting the chats');
},
success:function(data){
if(this.isMounted()){
this.setState({
chats: data.results
});
}
}.bind(this)
})
}
ComponentDidMount (){
this.interval = setInterval(function(){
this.getCharts();
}.bind(this),1000)
}
ComponentWillUnmount(){
clearInterval(this.interval);
}
render(){
var list = this.state.chats.map((item,index)=>{
return <li className = "list-group-item" key={item.objectId}> {item.text} </li>
})
return (
<ul className="list-group">
{list}
</ul>
)
}
}
ChatList.PropTypes = {
URL: props.string.isRequired
};
ChatList.defaultProps = {
URL: 'https://api.parse.com/1/classes/chat/'
};
export default ChatList;