reactjs / react-rails

Integrate React.js with Rails views and controllers, the asset pipeline, or webpacker.
Apache License 2.0
6.75k stars 759 forks source link

es6 import/export #361

Closed rileytg closed 7 years ago

rileytg commented 9 years ago

This is related to #238

i have a (mostly– no classes) es6 react component in another repo (i want to use in two rails apps) like this:

import React from 'react'

export var MyComponent = React.createClass({ 
  render: function () {
    return <div>Hello World</div>;
  }
})

any options other than the window.MyComponent?

vadimsg commented 8 years ago

I have similar problem with es6 class export and your solution with window kinda dont work. I'm trying to do that with Laravel using package react-laravel which is inspired by react-rails https://github.com/talyssonoc/react-laravel/issues/54

So no ideas any one? Have to stick with es5 for the moment?

mikeLspohn commented 8 years ago

Has anyone found a way to make this work with import/export?

danott commented 8 years ago

For es6 style imports and exports, you might be interested in checking out Shopify's sprockets-commoner.

rmosolgo commented 7 years ago

Also, webpacker https://github.com/rails/webpacker