# React 常见问题
# 在ES6中的super()和super(props)有什么区别
There is only one reason when one needs to pass props to super():
When you want to access this.props in constructor.
Note that passing or not passing props to super has no effect on later uses of this.props outside constructor. That is render, shouldComponentUpdate, or event handlers always have access to it.
唯一的区别就是如果你想在constructor()
中使用this.props的时候,你应该使用super(props)
,否则就用super()
就可以。 这对在constructor外部使用this.props
没有任何影响
参考:https://stackoverflow.com/questions/30571875/whats-the-difference-between-super-and-superprops-in-react-when-using-e
← React Links React 16 →