0

I am trying to use a component via NPM called React-TimeAgo. I have managed to install it via NPM and have Webpack integrated with Rails to generate a webpack bundle our of my node_modules.

This is all working fine when I import a Javascript library (like bootstrap) but not working with this React TimeAgo component. I think its the way I am trying to import from Webpack.

In my index.js I have:

window.bs = require('react-bootstrap')      <- this is working
window.timeago = require('react-timeago')   <- I don't think this is

And then in the view I have:

<%= react_component "TimeAgo", {date: 'Aug 29, 2014'} %>

But I get a runtime error saying the component TimeAgo could not be found.

What am I missing? Any assistance greatly appreciated.

BarrieH
  • 373
  • 3
  • 11
  • `var TimeAgo = require('react-timeago')` Heres a nice starter on importing node modules you install from npm: http://www.sitepoint.com/understanding-module-exports-exports-node-js/ – omarjmh Apr 07 '16 at 04:49
  • Can you provide the whole view and layout templates? Also i suggest you to read the following blog: http://blog.arkency.com/2015/11/arkency-react-dot-js-resources/ This guys have done nice job describing their experience with react + rails – Sergei Panfilov Apr 07 '16 at 06:03

0 Answers0