Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

usage with gulp? #30

Open
aprilmintacpineda opened this issue Nov 16, 2016 · 1 comment
Open

usage with gulp? #30

aprilmintacpineda opened this issue Nov 16, 2016 · 1 comment

Comments

@aprilmintacpineda
Copy link

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>';
@andrewpillar
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants