react-php-v8js
react-php-v8js copied to clipboard
usage with gulp?
this is the usage example you provided:
// the library
$react_source = file_get_contents('/path/to/build/react.js');
// all custom code concatenated
$app_source = file_get_contents('/path/to/custom/components.js');
$rjs = new ReactJS($react_source, $app_source);
$rjs->setComponent('MyComponent', array(
'any' => 1,
'props' => 2
)
);
/// ...
// print rendered markup
echo '<div id="here">' . $rjs->getMarkup() . '</div>';
/// ...
// load JavaScript somehow - concatenated, from CDN, etc
// including react.js and custom/components.js
// init client
echo '<script>' . $rjs->getJS("#here") . '</script>';
/// ...
// repeat setComponent(), getMarkup(), getJS() as necessary
// to render more components
I'm not sure if the following lines will be applicable if I am using gulp and laravel-elixir to mix all my scripts into a single file.
$app_source = file_get_contents('/path/to/custom/components.js');
echo '<script>' . $rjs->getJS("#here") . '</script>';
It would perhaps be best to keep the React source in a separate file for component rendering. But other than that if you're mixing all of your component script files into one file then you should have no issues.