react native arrow functions and if statements

前端 未结 1 1739
时光说笑
时光说笑 2021-01-16 22:25

I have just been schooled on arrow functions, and how they can aid with visibility when you start using sub-functions, here: react native and globally accessible objects

相关标签:
1条回答
  • 2021-01-16 23:00

    myFunction() is a class level function. Binding anything to this is referring a class itself, therefore you need to bind it to access this property, otherwise you won't be able to access the class level props.

    Although there are many ways to bind this as explained here, but the simplest one would be to use the shorthand arrow syntax as

    myFunction = () =>
    
    0 讨论(0)
提交回复
热议问题