目前我的组件渲染了4次。看起来它正在为每个道具渲染。如果我删除了除网络之外的道具,那么它只渲染一次,但是我确实需要其他道具。我在componentDidUpdate中使用了if语句,因为我需要检测更改,但是我渲染了4次,并且我的网络属性是相同的 export class Camera extends Component {
componentDidUpdate(prevProps, prevState){
if (prevProps.network !== this.props.network){
this.connect(this.props.network)