react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / dom / components / createFullPageComponent.js
81165 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule createFullPageComponent9* @typechecks10*/1112"use strict";1314// Defeat circular references by requiring this directly.15var ReactCompositeComponent = require('ReactCompositeComponent');16var ReactElement = require('ReactElement');1718var invariant = require('invariant');1920/**21* Create a component that will throw an exception when unmounted.22*23* Components like <html> <head> and <body> can't be removed or added24* easily in a cross-browser way, however it's valuable to be able to25* take advantage of React's reconciliation for styling and <title>26* management. So we just document it and throw in dangerous cases.27*28* @param {string} tag The tag to wrap29* @return {function} convenience constructor of new component30*/31function createFullPageComponent(tag) {32var elementFactory = ReactElement.createFactory(tag);3334var FullPageComponent = ReactCompositeComponent.createClass({35displayName: 'ReactFullPageComponent' + tag,3637componentWillUnmount: function() {38invariant(39false,40'%s tried to unmount. Because of cross-browser quirks it is ' +41'impossible to unmount some top-level components (eg <html>, <head>, ' +42'and <body>) reliably and efficiently. To fix this, have a single ' +43'top-level component that never unmounts render these elements.',44this.constructor.displayName45);46},4748render: function() {49return elementFactory(this.props);50}51});5253return FullPageComponent;54}5556module.exports = createFullPageComponent;575859