mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
Whenever we do this, Rollup needs to materialize this as an object. This causes it to also add the Babel compatibility property which is unnecessary bloat. However, since when we use these, we leak the object this often also deopts any compiler optimizations. If we really need an object we should export default an object. Currently there is an exception for DOMTopLevelEventTypes since listing out the imports is a PITA and it doesn't escape so it should get properly inlined. We should probably move to a different pattern to avoid this for consistency though. |
||
|---|---|---|
| .. | ||
| npm | ||
| src | ||
| index.fb.js | ||
| index.js | ||
| package.json | ||
| README.md | ||
| server.browser.js | ||
| server.js | ||
| server.node.js | ||
| test-utils.js | ||
| unstable-native-dependencies.js | ||
react-dom
This package serves as the entry point to the DOM and server renderers for React. It is intended to be paired with the generic React package, which is shipped as react to npm.
Installation
npm install react react-dom
Usage
In the browser
var React = require('react');
var ReactDOM = require('react-dom');
class MyComponent extends React.Component {
render() {
return <div>Hello World</div>;
}
}
ReactDOM.render(<MyComponent />, node);
On the server
var React = require('react');
var ReactDOMServer = require('react-dom/server');
class MyComponent extends React.Component {
render() {
return <div>Hello World</div>;
}
}
ReactDOMServer.renderToString(<MyComponent />);
API
react-dom
findDOMNoderenderunmountComponentAtNode
react-dom/server
renderToStringrenderToStaticMarkup