How to use the react-dom/server.renderToStaticMarkup function in react-dom

To help you get started, we’ve selected a few react-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apiaryio / attributes-kit / test / fixturesComparision.js View on Github external
}

        // to minim
        const minimNamespace = new Namespace();
        dataStructureElements = minimNamespace.fromRefract(dataStructureElements);

        renderedElement = React.createElement(Attributes, {
          element: dataStructureElements.first,
          dataStructures: dataStructureElements,
          collapseByDefault: false,
          maxInheritanceDepth: undefined,
          includedProperties: 'show',
          inheritedProperties: 'show',
        });

        htmlString = ReactDomServer.renderToStaticMarkup(renderedElement);
      });
github jinzhubaofu / ei / test / client / spec / util / connect.spec.js View on Github external
},
            // actions
            {
                hello
            }
        );

        const context = {
            store: {
                name: 'ludafa'
            },
            dispatch
        };


        const result = ReactDOM.renderToStaticMarkup(
            
                
            
        );

        expect(result).toBe('<div>I am ludafa and I am 18</div>');


    });
github unfoldingWord / translationCore / src / js / components / projectValidation / ProjectInformationCheck / index.js View on Github external
function getResourceInfoHint() {
      const infoText = translate('project_validation.resource_id.info');

      if (typeof infoText !== 'string') { // if translate wrapped as react element
        let html = ReactDOMServer.renderToStaticMarkup(infoText);

        if (html) {
          // remove span wrapper if present
          let parts = html.split('<span>');
          html = parts[0] || parts[1];
          parts = html.split('</span>');
          html = parts[0];
          return html;
        }
      }
      return infoText;
    }
github apache / incubator-spot / spot-oa / ui / js / components / SuspiciousGridMixin.react.js View on Github external
_renderRepCell: function (keyPrefix, reps) {
        var keys, services, tooltipContent;

        keys = Object.keys(reps);
        if (keys.length===0) return '';

        services = keys.map(function (key, idx) {
            return (
                <p>
                    <span>{key}: </span>
                    <span>{reps[key].text}</span>
                </p>
            );
        });

        tooltipContent = ReactDOMServer.renderToStaticMarkup(
            <div>
                {services}
            </div>
        );

        return (
            <span data-content="{tooltipContent}" data-placement="right" data-toggle="popover" data-container="body">
            </span>
        );
    },
    // Event Hanlders
github pivotal-cf / pivotal-ui / spec / pivotal-ui-react / svg / svg_spec.js View on Github external
it('works on a server', () =&gt; {
    const markup = ReactDOMServer.renderToStaticMarkup();
    expect(markup).toEqual('<svg class="im-on-a-server"></svg>');
  });
github Shopify / quilt / packages / react-html / src / server / render.ts View on Github external
export default function render(tree: ReactElement) {
  return `${renderToStaticMarkup(tree)}`;
}
github devarchy / website / server / http / client / html.js View on Github external
start_timer: true,
            tags: ["performance", "react_render"],
            message: "React element computed for `"+args.pathname+"`",
        }); 
        const element = page_section.section__element(args);
        timerlog({ 
            id: 'compute_element',
            end_timer: true,
        }); 
        timerlog({ 
            id: 'render_element',
            start_timer: true,
            tags: ["performance", "react_render"],
            message: "React element rendered to static markup for `"+args.pathname+"`",
        }); 
        const section_html = ReactDomServer.renderToStaticMarkup(element);
        timerlog({ 
            id: 'render_element',
            end_timer: true,
        }); 
        return section_html;
    }
}
github btnwtn / react-real-math / index.js View on Github external
export const computeValue = (component) =&gt; (
  parseInt(
    ReactDOMServer.renderToStaticMarkup(component)
    .match(/&lt;.*?&gt;(.*?)&lt;\/.*?&gt;/i)[1]
  )
)
github orbiting / publikator-frontend / components / editor / modules / chart / Export / utils.js View on Github external
export const getSvgNode = (chartElement, width = 660) => {
  const html = ReactDOMServer.renderToStaticMarkup(
    React.cloneElement(chartElement, {
      width: 660
    })
  )
  const template = document.createElement('template')
  template.innerHTML = html

  const svg = document.importNode(template.content.querySelector('svg'), true)
  svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
  svg.style.margin = '0 auto'
  return svg
}