How to use the renderToStaticMarkup function from react

Find comprehensive JavaScript react.renderToStaticMarkup code examples handpicked from public code repositorys.

1
2
3
4
5
6
7
8
9
10
var React = require('react')
var Cog = require('./Cog')

var build = function(name, props) {

  var svg = React.renderToStaticMarkup(React.createElement(Cog, props))
  
  fs.writeFileSync('icons/' + name + '.svg', svg)

}
fork icon13
star icon135
watch icon9

44
45
46
47
48
49
50
51
52
53
var list = fs.readdirSync(ENTRIES_DIR).filter(function(dir) {
  return isDirectory(path.join(ENTRIES_DIR, dir));
}).map(function (dir) {
  return React.DOM.li({}, React.DOM.a({href: '/'+dir}, dir.replace(/-/g, ' ')));
});
var markup = React.renderToStaticMarkup((
  React.DOM.html({},
    React.DOM.link({rel: 'stylesheet', href: '/shared.css'}),
    React.DOM.body({id: "index"},
      React.DOM.ul({}, list)
fork icon7
star icon101
watch icon7

9
10
11
12
13
14
15
16
17
18
  TestUtils = require('react-addons-test-utils');
}

function renderToStaticMarkup(element) {
  if (React013) {
    return React.renderToStaticMarkup(element);
  }

  return require("react-dom/server").renderToStaticMarkup(element);
}
fork icon39
star icon0
watch icon2

48
49
50
51
52
53
54
55
56
57
/**
 * Just produce static markup without data-react-* attributes
 * http://facebook.github.io/react/docs/top-level-api.html#react.rendertostaticmarkup
 */
function renderToStaticMarkup(page) {
  return React.renderToStaticMarkup(React.createElement(page));
}

// Plugin level function (dealing with files)
function Plugin(options) {
fork icon9
star icon26
watch icon2

104
105
106
107
108
109
110
111
112
113
  container,
  horizontalAlignment,
  verticalAlignment,
  browserSupport
);
var code = React.renderToStaticMarkup(parent);
var formattedCode = html.prettyPrint(
  code,
  {
    indent_size: 2,
fork icon48
star icon0
watch icon20

+ 3 other calls in file