I'm using the public class field syntax (handler = () => {...}
) to define all my React components' event handlers so that I can use this
for my components without binding them in the constructor
. I'm wondering can I use this syntax to use React life cycle methods as well? Say use componentWillMount
in this way: componentWillMount = () => {...}
What are the pros and cons if defining react's life cycle method with arrow functions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…