相关疑难解决方法(0)

将有状态React组件转换为无状态功能组件:如何实现"componentDidMount"类功能?

我写了一个小的有状态React组件.加载此组件时,在componentDidMount方法I中,我使用Kendo UI在弹出窗口中显示组件的内容.

这是我的代码:

export class ErrorDialog extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.errorPopupWindow = null;
    window.addEventListener('resize', this.resizeComponent);
    this.handleWindowKeyDown = this.handleWindowKeyDown.bind(this);
    this.handleButtonCloseWindowOnClick = this.handleButtonCloseWindowOnClick.bind(this);
    this.handleButtonShowDetailsOnClick = this.handleButtonShowDetailsOnClick.bind(this);
    $('#ErrorInformationForm-CloseWindow').focus();
  }

  render() {
    const errorInformation = this.props.errorInformation;
    const baseException = errorInformation.baseException;
    const showExceptionMessage = (typeof baseException !== 'undefined' && typeof baseException === 'object' && baseException !== null
          && typeof baseException.message !== 'undefined' && typeof baseException.message === 'string' && baseException.message !== null
          && baseException.message !== '') ? true : false; …
Run Code Online (Sandbox Code Playgroud)

javascript dom event-handling window-load reactjs

6
推荐指数
1
解决办法
1926
查看次数

标签 统计

dom ×1

event-handling ×1

javascript ×1

reactjs ×1

window-load ×1