php-V8Jsを使用して、PHPサーバでリアクションレンダリングを実行しようとしています。サーバでレンダリングされていないリアクタルータ
単一のコンポーネントはうまく描画されますが、<RouterContext />
を使用して子をレンダリングする際に問題があります。
<?php
$v8js = new V8Js();
ob_start();
$v8js->executeString(file_get_contents(PUBLIC_PATH . '/js/bundle.js'), 'v8.js');
$content = ob_get_clean();
echo $content;
App.jsx(bundle.js)
import React from 'react'
import { render } from 'react-dom'
import { Router, Route, Link, browserHistory, IndexRoute, match, RouterContext } from 'react-router'
import Master from './views/Master.jsx';
import About from './views/About.jsx';
var routes = {
path: '/',
component: 'Master',
indexRoute: {
component: 'About'
}
}
if (typeof document === 'undefined'){
match({
routes,
location: '/'
},
function(error, redirectLocation, renderProps) {
print(React.renderToString(<RouterContext {...renderProps}/>));
})
}
これがクライアントに送信元のHTMLは次のとおりです。
<Master data-reactid=".1dpk2jzhts0" data-react-checksum="2085756513">
<About data-reactid=".1dpk2jzhts0.0"></About>
</Master>
それはどちらかのコンポーネントのHTMLのいずれかを含めていません。
Iは<About />
又は<Master />
レンダリングされるいずれかのHTMLのため<RouterContext/>
をスワップアウトが、RouterContextを使用する場合は、各コンポーネントのルートタグをレンダリングする場合。
私が間違っていることは何ですか?
コンポーネントの文字列を渡すためですか?インポートされたコンポーネント「マスター」ではなく「マスター」になりますか? – Petecoop