bit*_*eam 13 javascript reactjs
基本上,我有这个非常简单的反应组件.它的作用是环绕'react-intercom',只有在状态发生变化时才会渲染它.为了简化问题,我已经将该shouldCompoenentUpdate()方法硬连接以始终返回false.
import React from 'react';
import Intercom from 'react-intercom';
class IntercomWrapper extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
// console.log(!!nextProps.user && nextProps.user.userId !== this.props.user.userId);
// return !!nextProps.user && nextProps.user.userId !== this.props.user.userId;
return false;
}
render() {
console.log('rendering');
return <Intercom {...this.props} />;
}
};
export default IntercomWrapper;Run Code Online (Sandbox Code Playgroud)
会发生什么事情,它总是会重新渲染,这不应该发生.
任何人都知道为什么会发生这种情况?
| 归档时间: |
|
| 查看次数: |
7532 次 |
| 最近记录: |