React.js - Syntax error: this is a reserved word in render() function

后端 未结 3 1786
情书的邮戳
情书的邮戳 2020-11-28 09:56

I\'m stuck on a error for the reserved keyword \"this\". In my React Component below shows me passing in a state from a my main component \"App.js\" to my \"RecipeList.js\"

3条回答
  •  一生所求
    2020-11-28 10:33

    Wrap the this.renderRecipeItems() part with a div, it will work.

    Reason why it was failing, is explained extremely well by @nem035 in this answer.

    Like this:

    render () {
       return (
          
    { this.renderRecipeItems() }
    ); }

    And i think instead of:

    
    

    It should be:

    
    

    These are the changes i can see, may be some others will be required also.

提交回复
热议问题