How to integrate react js into game web app

I am trying to create a web application using a replay framework and I want to use js for the frontend. How do I integrate react js into my game web app?

+3


source to share


2 answers


I have zero knowledge of the loading platform, but it is not difficult to integrate react in a web application.

if you compiled the js react jsj file. just include in the heading tag on your index page. and declare div with id. and then do some code like this

Html

<div id="root">
 <!-- This element contents will be replaced with your component. -->
</div>

      



reactjs

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

      

demo: http://codepen.io/gaearon/pen/rrpgNB?editors=1010

and this blog article might be helpful for solving your problem https://facebook.github.io/react/docs/rendering-elements.html

0


source


I think the best way to manage dependencies in a Play app is through WebJars. First, add the WebJars dependency tobuild.sbt

libraryDependencies ++= Seq(
  "org.webjars" %% "webjars-play" % "2.5.0",
  "org.webjars" % "bootstrap" % "3.1.1-2"
)

      

Now you have to declare the asset routes in the file routes



GET / assets / * file controllers .Assets.at (path = "/ public", file) GET / webjars / * file controllers .WebJarAssets.at (file)

Then you can add a reaction to the HTML file:

<head>
    <script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.fullPath("react", "react.js"))'></script>
</head>

      

0


source







All Articles