From: Drew Fisher Date: Sun, 18 May 2014 02:04:03 +0000 (-0700) Subject: Add propTypes to everything that takes React props X-Git-Url: http://git.zarvox.org/login?a=commitdiff_plain;h=a9f7d81f9ff261aeaaab9a54bf1ec4d1cf98d6dc;p=imoo.git Add propTypes to everything that takes React props --- diff --git a/reactornado/widgets.js b/reactornado/widgets.js index cb3e325..4565eba 100644 --- a/reactornado/widgets.js +++ b/reactornado/widgets.js @@ -41,6 +41,11 @@ var LoginForm = React.createClass({ // Buddy list stuff var BuddyListItem = React.createClass({ + propTypes: { + bicon_url: React.PropTypes.string, + display_name: React.PropTypes.string.isRequired, + status_msg: React.PropTypes.string + }, render: function () { return
@@ -84,6 +89,13 @@ var BuddyList = React.createClass({ }); var ConversationTab = React.createClass({ + // TODO: consider DRY-ing these propTypes up by making some model classes? + propTypes: { + buddy: React.PropTypes.shape({ + display_name: React.PropTypes.string.isRequired, + }).isRequired, + onClick: React.PropTypes.func.isRequired + }, render: function() { var classname = "conv-tab"; if (this.props.active) { @@ -95,6 +107,15 @@ var ConversationTab = React.createClass({ }); var ConversationTabBar = React.createClass({ + propTypes: { + tabs: React.PropTypes.arrayOf( + React.PropTypes.shape({ + display_name: React.PropTypes.string.isRequired, + }).isRequired + ).isRequired, + onTabSwitch: React.PropTypes.func.isRequired, + focused_tab: React.PropTypes.number + }, render: function() { var tabs = []; for (var i = 0 ; i < this.props.tabs.length ; i++) { @@ -111,6 +132,9 @@ var ConversationTabBar = React.createClass({ var ConversationTextEntry = React.createClass({ mixins: [React.addons.LinkedStateMixin], + propTypes: { + onSendMessage: React.PropTypes.func.isRequired + }, getInitialState: function() { return {"text": ""}; }, @@ -130,6 +154,18 @@ var ConversationTextEntry = React.createClass({ }); var ConversationTabContent = React.createClass({ + propTypes: { + messages: React.PropTypes.arrayOf(React.PropTypes.shape({ + direction: React.PropTypes.string.isRequired, + timestamp: React.PropTypes.string.isRequired, + text: React.PropTypes.string.isRequired + })).isRequired, + buddy: React.PropTypes.shape({ + id: React.PropTypes.string.isRequired, + display_name: React.PropTypes.string.isRequired + }), + onSendMessage: React.PropTypes.func.isRequired + }, render: function() { var messages = []; for (var i = 0 ; i < this.props.messages.length ; i++) {