-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
83 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import React from 'react' | ||
import { StaticRouter } from 'react-router-dom' | ||
import MetaTagsServer from 'react-meta-tags/lib/meta_tags_server'; | ||
import { MetaTagsContext } from 'react-meta-tags/lib/index'; | ||
|
||
import App from './App' | ||
|
||
var context = {} | ||
|
||
export const metaTagsInstance = MetaTagsServer(); | ||
|
||
export default (props) => ( | ||
<StaticRouter location={props.location} context={context}> | ||
<App/> | ||
</StaticRouter> | ||
<MetaTagsContext extract = {metaTagsInstance.extract}> | ||
<StaticRouter location={props.location} context={context}> | ||
<App/> | ||
</StaticRouter> | ||
</MetaTagsContext> | ||
) |
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 @@ | ||
const app = require('./build/server.compiled.js') | ||
let html = ReactDomServer.renderToString(app) | ||
|
||
let template = ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
${meta} | ||
</head> | ||
<body> | ||
<div id="app">${html}</div> | ||
<script src="build/client.compiled.js"></script> | ||
</body> | ||
</html> | ||
` |
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,19 @@ | ||
<?php | ||
|
||
namespace Chenos\ExecJs\ReactRouter; | ||
|
||
class Response | ||
{ | ||
public function status($status) | ||
{ | ||
http_response_code($status); | ||
|
||
return $this; | ||
} | ||
|
||
public function send($html) | ||
{ | ||
echo $html; | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
var React = require('react') | ||
var ReactDOMServer = require('react-dom/server') | ||
var App = require('./build/server.compiled.js').default | ||
var metaTagsInstance = require('./build/server.compiled.js').metaTagsInstance | ||
|
||
for (var i = 0; i < 10000; i++) { | ||
var element = React.createElement(App, { location: '/react-router/' }) | ||
var element = React.createElement(App, { location: '/react-router/about' }) | ||
var html = ReactDOMServer.renderToString(element) | ||
} | ||
|
||
// if (typeof print === 'undefined') { | ||
// global.print = console.log | ||
// } | ||
|
||
// print(html) | ||
if (typeof print === 'undefined') { | ||
global.print = console.log | ||
} | ||
const meta = metaTagsInstance.renderToString(); | ||
print(meta) | ||
print(html) |
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