How can I get a php backend var into my reactjs (using react-router) via webpack.
I want to do something like:
<?php
if ($us->inGroup('Admin')) { ?>
<script>
var groups = true
</script>
<?php
}
?>
Then use that var groups
inside my reactjs app via webpack (inside the bundle.js)
Here, where my reactjs app is -> <script type="application/javascript" src="/bundle.js"></script>
Thank you.
You don't need Webpack to do this. You just need to make sure that the
groups
variable is in the global scope. In your.php
file, set thegroups
value by using a ternary statement to echotrue
orfalse
based on the value return from theinGroup
call.