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.
http://remarkablemark.org/blog/2016/09/24/react-requirejs-amd/
Let's take that and integrate it into an Oracle JET module.
- Include
in Bower dependencies: "react": "15.3.2"
- Include
in "paths" in bootstrap file, i.e., "main.js":
'react': 'libs/react/react.min', 'react-dom': 'libs/react/react-dom.min'
- 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(); } );
- 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.