I'm learning React.js with Rails 4.2 (to prepare to work on it) but I have a lot of errors in my console.
So I'm using React 16.8 (with react-rails gem) + Rails 4.2 + Webpacker 4.0.2
My folders structure:
app
|
javascript
|
packs
|
application.js
server_rendering.js
components
|
main.js.jsx
header.js.jsx
body.js.jsx
new_item.js.jsx
all_items.js.jsx
In my application layout, I added = javascript_pack_tag('application')
In my index view, I have = react_component('Main')
But I have these errors:
var componentRequireContext = require.context("components", true);
var ReactRailsUJS = require("react_ujs");
ReactRailsUJS.useContext(componentRequireContext);
main.js.jsx :
var Main = React.createClass({
render() {
return (
<div>
<Header />
<Body />
</div>
);
}
});
I tried to add import React from ‘react’
in main.js.jsx
but I still have the errors.
this is the first time I use React, I do not know where to look... Any help would be very appreciate
Thanks