示例:
class MyComponent extends React.Component {
componentWillReceiveProps(nextProps) {
if (nextProps.somethingHappened) {
return
}
otherThingHappened()
}
}
示例:
class MyComponent extends React.Component {
componentWillReceiveProps(nextProps) {
if (nextProps.somethingHappened) {
return null
}
otherThingHappened()
}
}
答案 0 :(得分:4)
不是。根据{{3}} componentWillReceiveProps
预计不会返回任何内容。虽然返回一个将在之后被丢弃的值,但这似乎很奇怪。