SHARE
TWEET

Untitled

a guest Sep 16th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2. import ReactDOM from 'react-dom'
  3. import ReactDOMServer from 'react-dom/server'
  4.  
  5. class Navigation extends Component {
  6.   render() {
  7.     return (
  8.       <ul>
  9.         <li>Main</li>
  10.         <li>About</li>
  11.         <li>Other</li>
  12.       </ul>
  13.     )
  14.   }
  15. }
  16. class HtmlPageTemplate extends Component {
  17.   render() {
  18.     return (
  19.       <html lang="ru">
  20.         <head>
  21.           <title>Test page</title>
  22.           <link type="content/style" href="style.css" />
  23.         </head>
  24.         <body>
  25.           <h1 className="pageTitle">Hello world</h1>
  26.           <p>Some text.</p>
  27.           <Navigation />
  28.         </body>
  29.       </html>
  30.     )
  31.   }
  32. }
  33.  
  34. const staticReactHtml = ReactDOMServer.renderToStaticMarkup(
  35.   React.createElement(HtmlPageTemplate, null)
  36. )
  37. console.log('<!DOCTYPE html>\n' + staticReactHtml)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top