Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: move server side rendering code to separate file to avoid loadin…
…g react-dom on the client
- Loading branch information
1 parent
bddb8a0
commit 0c3f312
Showing
4 changed files
with
91 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import DocumentMeta, { render } from './index'; | ||
import React from 'react'; | ||
import { renderToStaticMarkup } from 'react-dom/server'; | ||
|
||
function rewindAsStaticMarkup() { | ||
const tags = render(DocumentMeta.rewind()); | ||
|
||
return renderToStaticMarkup(<div>{tags}</div>) | ||
.replace(/(^<div>|<\/div>$)/g, '') | ||
.replace(/data-rdm="true"/g, 'data-rdm'); | ||
} | ||
|
||
export default DocumentMeta; | ||
|
||
DocumentMeta.renderToStaticMarkup = rewindAsStaticMarkup; | ||
DocumentMeta.renderAsHTML = rewindAsStaticMarkup; |