Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81165 views
1
/**
2
* Copyright 2013-2014, 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
* @providesModule ReactDOMOption
10
*/
11
12
"use strict";
13
14
var ReactBrowserComponentMixin = require('ReactBrowserComponentMixin');
15
var ReactCompositeComponent = require('ReactCompositeComponent');
16
var ReactElement = require('ReactElement');
17
var ReactDOM = require('ReactDOM');
18
19
var warning = require('warning');
20
21
// Store a reference to the <option> `ReactDOMComponent`. TODO: use string
22
var option = ReactElement.createFactory(ReactDOM.option.type);
23
24
/**
25
* Implements an <option> native component that warns when `selected` is set.
26
*/
27
var ReactDOMOption = ReactCompositeComponent.createClass({
28
displayName: 'ReactDOMOption',
29
30
mixins: [ReactBrowserComponentMixin],
31
32
componentWillMount: function() {
33
// TODO (yungsters): Remove support for `selected` in <option>.
34
if (__DEV__) {
35
warning(
36
this.props.selected == null,
37
'Use the `defaultValue` or `value` props on <select> instead of ' +
38
'setting `selected` on <option>.'
39
);
40
}
41
},
42
43
render: function() {
44
return option(this.props, this.props.children);
45
}
46
47
});
48
49
module.exports = ReactDOMOption;
50
51