Implement React JS in Yii2 Can we use React JS in only one module of existing project
Posted 11 January 2017 - 01:25 AM
So anyone please tell me is it possible or not?
Posted 11 January 2017 - 02:20 AM
Posted 11 January 2017 - 07:49 AM
Thanks for the suggestion. Is it possible to call react component in Yii2 layout file for ex: In my dashboard side bar and header will be from yii2 layout but middle container will be of React Component.
If is possible then how can we do it? I have included js files in my view along with react component.
import React from 'react';
import ReactDOM from 'react-dom';
But it is now working, react js file is calling but did not rendering react html in yii2 view
Posted 12 January 2017 - 03:20 AM
<div id="react-app"></div> ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('react-app') );
Posted 13 January 2017 - 02:10 AM
<script> ReactDOM.render( <h1>Hello, world</h1> document.getElementById('root')); </script>
I am getting an error "Uncaught SyntaxError: Unexpected token <" at the line "<h1>Hello, world</h1>