Skip to content

Instantly share code, notes, and snippets.

@koriym
Created May 8, 2016 04:30
Show Gist options
  • Save koriym/719eb30baaa83ba07ef1dbb243439672 to your computer and use it in GitHub Desktop.
Save koriym/719eb30baaa83ba07ef1dbb243439672 to your computer and use it in GitHub Desktop.
SSR code sample
<!doctype html>
<html>
<head>
<title>React page</title>
<!-- css and stuff -->
</head>
<body>
<!-- render server content here -->
<div id="page"><table data-reactid=".mnp5ckk6ea" data-react-checksum="615955299"><tbody data-reactid=".mnp5ckk6ea.0"><tr data-reactid=".mnp5ckk6ea.0.0"><td data-reactid=".mnp5ckk6ea.0.0.0">1</td><td data-reactid=".mnp5ckk6ea.0.0.1">2</td><td data-reactid=".mnp5ckk6ea.0.0.2">3</td></tr><tr data-reactid=".mnp5ckk6ea.0.1"><td data-reactid=".mnp5ckk6ea.0.1.0">4</td><td data-reactid=".mnp5ckk6ea.0.1.1">5</td><td data-reactid=".mnp5ckk6ea.0.1.2">6</td></tr><tr data-reactid=".mnp5ckk6ea.0.2"><td data-reactid=".mnp5ckk6ea.0.2.0">7</td><td data-reactid=".mnp5ckk6ea.0.2.1">8</td><td data-reactid=".mnp5ckk6ea.0.2.2">9</td></tr></tbody></table></div>
<!-- load react and app code -->
<script src="react/build/react.min.js"></script>
<script src="build/table.js"></script>
<script>
// client init/render
// this is a straight echo of the JS because the JS resources
// were loaded synchronously
// You may want to load JS async and wrap the return of getJS()
// in a function you can call later
var GLOB = ReactDOM.render(React.createElement(Table, {"data":[[1,2,3],[4,5,6],[7,8,9]]}), document.getElementById("page")); </script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment