Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80684 views
1
/**
2
* Copyright (c) 2014-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*/
9
10
var React = require('react');
11
var TodoActions = require('../actions/TodoActions');
12
var TodoTextInput = require('./TodoTextInput.react');
13
14
var Header = React.createClass({
15
16
/**
17
* @return {object}
18
*/
19
render: function() {
20
return (
21
<header id="header">
22
<h1>todos</h1>
23
<TodoTextInput
24
id="new-todo"
25
placeholder="What needs to be done?"
26
onSave={this._onSave}
27
/>
28
</header>
29
);
30
},
31
32
/**
33
* Event handler called within TodoTextInput.
34
* Defining this here allows TodoTextInput to be used in multiple places
35
* in different ways.
36
* @param {string} text
37
*/
38
_onSave: function(text) {
39
if (text.trim()){
40
TodoActions.create(text);
41
}
42
43
}
44
45
});
46
47
module.exports = Header;
48
49