expected assignment or function call: no-unused-expressions ReactJS

前端 未结 14 803
挽巷
挽巷 2020-12-07 16:26
class Game extends Component 
{
  constructor() 
  {
    super()
    this.state = {
      speed: 0
    }
    //firebaseInit()
  }
  render()
  {
    return 
    (
           


        
14条回答
  •  北海茫月
    2020-12-07 16:52

    In case someone having a problem like i had. I was using the parenthesis with the return statement on the same line at which i had written the rest of the code. Also, i used map function and props so i got so many brackets. In this case, if you're new to React you can avoid the brackets around the props, because now everyone prefers to use the arrow functions. And in the map function you can also avoid the brackets around your function callback.

    props.sample.map(function callback => (
       ));
    

    like so. In above code sample you can see there is only opening parenthesis at the left of the function callback.

提交回复
热议问题