* Create a component that will throw an exception when unmounted. * * Components like and can't be removed or added * easily in a cross-browser way, however it's valuable to be able to * take advantage of React's reconciliation for styling and * management. So
(tag)
| 27628 | * @return {function} convenience constructor of new component |
| 27629 | */ |
| 27630 | function createFullPageComponent(tag) { |
| 27631 | var elementFactory = ReactElement.createFactory(tag); |
| 27632 | |
| 27633 | var FullPageComponent = ReactClass.createClass({ |
| 27634 | tagName: tag.toUpperCase(), |
| 27635 | displayName: 'ReactFullPageComponent' + tag, |
| 27636 | |
| 27637 | componentWillUnmount: function() { |
| 27638 | ("production" !== process.env.NODE_ENV ? invariant( |
| 27639 | false, |
| 27640 | '%s tried to unmount. Because of cross-browser quirks it is ' + |
| 27641 | 'impossible to unmount some top-level components (eg <html>, <head>, ' + |
| 27642 | 'and <body>) reliably and efficiently. To fix this, have a single ' + |
| 27643 | 'top-level component that never unmounts render these elements.', |
| 27644 | this.constructor.displayName |
| 27645 | ) : invariant(false)); |
| 27646 | }, |
| 27647 | |
| 27648 | render: function() { |
| 27649 | return elementFactory(this.props); |
| 27650 | } |
| 27651 | }); |
| 27652 | |
| 27653 | return FullPageComponent; |
| 27654 | } |
| 27655 | |
| 27656 | module.exports = createFullPageComponent; |
| 27657 |