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:
http://remarkablemark.org/blog/2016/09/24/react-requirejs-amd/

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.

Todos los Sábados a las 8:00PM

Optimismo para una vida Mejor

Optimismo para una vida Mejor
Noticias buenas que comentar