首页 > 解决方案 > TypeError : Children 不是函数 react-visibility-sensor

问题描述

在构建时,此页面上有错误说明 TypeError : Children is not a function react-visibility-sensor

class VisibilitySensor extends Component {
  constructor(props) {
    super(props);
    this.state = {
      active: true
    };
  }

  render() {
    const { active } = this.state;
    const { once, children, ...theRest } = this.props;
    return (
      <VSensor
        active={active}
        onChange={isVisible =>
          once &&
          isVisible &&
          this.setState({ active: false })
        }
        {...theRest}
      >
        {({ isVisible }) => children({ isVisible })}
      </VSensor>
    );
  }
}

标签: javascriptreactjs

解决方案


推荐阅读