Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I integrate React into a Knockout JavaScript app?

I’ve been building an application in my spare time, its backend is C# and I use Knockout js for the front end, to be honest its an app I use out side of my main job for learning purposes etc, I may launch it one day not really sure. I’ve now a new job where they use React, so my question is can I now integrate React into my app so I can begin learning this library? I’d aim to keep each component separate but does anyone think this a bad idea mixing libraries like this? I haven’t learnt React yet hence I want to start integrating it into my side project though I don’t really want to start rewriting all the Knockout JavaScript again also.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A React app can be initialized on any DOM node you want. Pick a page you want to put React on, create a DOM node (a simple div) and create a Element on that node.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
    <title>Hello World</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      function App() {
        return <h1>Hello, world!</h1>
      }
      
      ReactDOM.render(
        <App />,
        document.getElementById('root')
      );
    </script>
  </body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading