viernes, 18 de noviembre de 2016

Oracle Blog´s React.js and Oracle JET

Here is a fantastic small example that works perfectly, showing how to combine React with Require:

Let's take that and integrate it into an Oracle JET module.
  1. Include in Bower dependencies: "react": "15.3.2"
  2. Include in "paths" in bootstrap file, i.e., "main.js":
    'react': 'libs/react/react.min',     'react-dom': 'libs/react/react-dom.min' 
  1. In your viewModel:
define(['ojs/ojcore', 'knockout', 'jquery', 'react', 'react-dom'],  function(oj, ko, $, React, ReactDOM) {     function HomeViewModel() {       var self = this;       self.handleAttached = function(info) {         ReactDOM.render(             React.createElement('h1', {}, 'hello from react!'),             document.getElementById('root')         );       };     }     return new HomeViewModel();   } ); 
  1. In your view:
And that's all. You'll see the message above in your page when you load it.

No hay comentarios:

Publicar un comentario

Te agradezco tus comentarios. Te esperamos de vuelta.