小编Ily*_*nov的帖子

似乎在ReactJS中的setState之后不会调用componentDidMount

学习ReactJS我正在研究一个简单的倒计时应用程序.倒计时组件如下所示:

const Countdown = React.createClass({
  getInitialState: function() {
    return {
      remaining: 10,
      running: true,
    };
  },
  componentDidMount: function(){
    if (this.state.running) {
      setInterval(this.tick, 1000);
    } else {
      console.log("already paused");
    };
  },
  tick: function(){
    if (this.state.remaining === 0) {
      this.setState({ remaining: 10 });
      this.props.updateStats();
    } else {
        this.setState({ remaining: this.state.remaining -1 });
    };

  },
  handlePauseClick: function(){
    this.setState({ running: false });
  },
  render: function(){
    const s = this.state.remaining;
    return (
      <div className='ui centered card'>
        <div className='content centered'>
          <h1>{helpers.secondsToHuman(s)}</h1>
          <ButtonControls
            handlePauseClick={this.handlePauseClick}
          />
        </div>
      </div> …
Run Code Online (Sandbox Code Playgroud)

reactjs

5
推荐指数
1
解决办法
2371
查看次数

带有 GitHub 的 AWS CodeBuild - 仅适用于特定目录

我正在尝试使用 AWS Pipeline、S3 和 CodeBuild 为 Angular 2 应用程序设置自动部署。

按照 Andrés 的教程,我能够将 CodeBuild 连接到 GitHub 存储库,并且该过程运行良好。

然而,我们的 Angular 应用程序位于更大的 repo 的子目录中。

有没有办法在 repo 中指定一个目录,以便只有在子目录更改时才会触发构建?

非常感谢。

github amazon-s3 amazon-web-services aws-codebuild

4
推荐指数
2
解决办法
5004
查看次数