UNPKG

844 BJavaScriptView Raw
1/**
2 * Copyright 2015, Yahoo Inc.
3 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
4 */
5'use strict';
6
7var React = require('react');
8
9/**
10 * Deprecates a component by logging a warning message when used
11 * @method deprecateComponent
12 * @param {React.Component} Component component to wrap
13 * @param {string} warningMessage Custom contextTypes to add
14 * @returns {React.Component}
15 */
16module.exports = function deprecateComponent(Component, warningMessage) {
17 var DeprecationComponent = React.createClass({
18 displayName: 'DeprecationComponent',
19
20 componentWillMount: function () {
21 console.warn(warningMessage);
22 },
23
24 render: function () {
25 return React.createElement(Component, this.props);
26 }
27 });
28
29 return DeprecationComponent;
30};