Ho deciso di imparare React e ho iniziato con il tutorial ufficiale. Tutto è bene fino a arrivare a questo stato del mio codice:React Tutorial: TypeError: Impossibile leggere la proprietà 'oggetti di scena' di undefined
var CommentBox = React.createClass({
render:() => {
return (
<div className="commentBox">
<h1> Comments </h1>
<CommentList />
<CommentForm />
</div>
);
}
});
var CommentForm = React.createClass({
render:() => {
return (
<div className="commentForm">
Hello, world! I am a comment form;
</div>
);
}
});
var Comment = React.createClass({
rawMarkup:() => {
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
return {__html: rawMarkup};
},
render:() => {
return (
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2> // <--- [[[[[[ ERROR IS HERE ]]]]]]
<span dangerouslySetInnerHtml={this.rawMarkup} />
</div>
);
}
});
var CommentList = React.createClass({
render:() => {
return (
<div className="commentList">
<Comment author="Pete Hunt">This is one comment</Comment>
<Comment author="Jordan Walke">This is *another* comment yo</Comment>
</div>
);
}
});
ReactDOM.render(
<CommentBox />,
document.getElementById('content')
);
Quando provo a farlo funzionare, ottengo il seguente errore nel devtools: "TypeError: Impossibile leggere proprietà 'oggetti di scena' di indefinito" e la debugger fa una pausa sulla linea segnata (vedi codice). Quando passo il mouse su "this" in {this.props.author} ottengo un'anteprima dell'oggetto che ha la proprietà "props" e tutto ...
Sono davvero nuovo per reagire, quindi è probabilmente qualcosa di stupido , ma chissà ...
Spero che voi ragazzi potete aiutare!
Cheers, H.
voglio aggiungere che stavo vedendo questo errore di recente a causa del strumenti di sviluppo reagire. Volevo solo lanciarlo perché questo è il miglior risultato di Google. – Donald