-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is for testing server rendering - on the client.
- Loading branch information
1 parent
f489e2a
commit 02e7020
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html style="width: 100%; height: 100%; overflow: hidden"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Fizz Example</title> | ||
</head> | ||
<body> | ||
<h1>Fizz Example</h1> | ||
<div id="container"> | ||
<p> | ||
To install React, follow the instructions on | ||
<a href="https://github.com/facebook/react/">GitHub</a>. | ||
</p> | ||
<p> | ||
If you can see this, React is <strong>not</strong> working right. | ||
If you checked out the source from GitHub make sure to run <code>npm run build</code>. | ||
</p> | ||
</div> | ||
<script src="../../build/dist/react.development.js"></script> | ||
<script src="../../build/dist/react-dom-unstable-fizz.browser.development.js"></script> | ||
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script> | ||
<script type="text/babel"> | ||
let stream = ReactDOMFizzServer.renderToReadableStream(<body>Success</body>); | ||
let response = new Response(stream, { | ||
headers: {'Content-Type': 'text/html'}, | ||
}); | ||
display(response); | ||
|
||
async function display(responseToDisplay) { | ||
let blob = await responseToDisplay.blob(); | ||
let url = URL.createObjectURL(blob); | ||
let iframe = document.createElement('iframe'); | ||
iframe.src = url; | ||
let container = document.getElementById('container'); | ||
container.innerHTML = ''; | ||
container.appendChild(iframe); | ||
} | ||
</script> | ||
</body> | ||
</html> |