该组件通过调用自己的回调来处理表单提交?在这种情况下调用自己的回调意味着什么?

时间:2015-06-04 07:42:47

标签: reactjs reactjs-flux

我正在学习反应器的通量架构,同时阅读本文:https://medium.com/brigade-engineering/what-is-the-flux-application-architecture-b57ebca85b9e

我似乎无法通过以下上下文中的“组件通过调用自己的回调来处理表单提交”来获取作者的含义:

// Saving a new ToDo calls the '_onSave' callback

var Header = React.createClass({

  /**
   * @return {object}
   */
  render: function() {
    return (
      <header id="header">
        <h1>todos</h1>
        <TodoTextInput
          id="new-todo"
          placeholder="What needs to be done?"
          onSave={this._onSave}
        />
      </header>
    );
  },

1 个答案:

答案 0 :(得分:2)

术语“回调”在这里可能不正确,但我认为他只是意味着他将1) ExampleTest::it_can_seach LogicException: The selected node does not have a form ancestor. /var/www/html/srs/vendor/symfony/dom-crawler/Form.php:400 /var/www/html/srs/vendor/symfony/dom-crawler/Link.php:55 /var/www/html/srs/vendor/symfony/dom-crawler/Form.php:49 /var/www/html/srs/vendor/symfony/dom-crawler/Crawler.php:770 /var/www/html/srs/vendor/laracasts/integrated/src/Extensions/IntegrationTrait.php:397 /var/www/html/srs/vendor/laracasts/integrated/src/Extensions/IntegrationTrait.php:380 /var/www/html/srs/vendor/laracasts/integrated/src/Extensions/Traits/LaravelTestCase.php:47 /var/www/html/srs/tests/ExampleTest.php:23 FAILURES! Tests: 2, Assertions: 8, Errors: 1. 类中定义的函数Header传递给子组件this._onSave所以提交TodoTextInput时,会调用TodoTextInput内的函数,因此Header无需了解它。