Help us help you! Please choose one:
react-rails, so I've included the stack trace and the exact steps which make it crash.react-rails with another library, but I'm having trouble. I've described my JavaScript management setup (eg, Sprockets, Webpack...), how I'm trying to use this other library, and why it's not working.This is not an issue, just a question. How would you go about using this https://github.com/reactjs/react-modal in your react-rails app?
I'm using Sprockets, here's how I'd do it:
/app/assets/javascripts/vendor/react-modal.js/app/assets/javascripts/vendor/react-modal-v1.0.0.jsjs
//= require react
//= require ./vendor/react-modal-v1.0.0
ReactModal variable in my code: js
// inside a component definition:
render: function() {
return (
<div>
<ReactModal />
</div>
)
}
@rmosolgo would you suggest a way this could be done with a non-compiled library, e.g https://github.com/andreypopp/autobind-decorator
People usually "compile" their compiles-to-JS languages before pushing to NPM, right? So npmcdn might have the compiled version: https://npmcdn.com/[email protected]
The only problem is that it looks like that is made for a NodeJS-like environment, I see that it assumes an object named exports exists.
You could remove those lines to prepare the file for the browser:
// Remove these: exports['default'] = autobind; //... module.exports = exports['default'];
Or, since this package is _meant_ to be used with Babel, maybe babel will take care of it?
React-rails 2.0.0 will support https://github.com/rails/webpacker which brings nodejs build processes to Rails!
Most helpful comment
I'm using Sprockets, here's how I'd do it:
/app/assets/javascripts/vendor/react-modal.js/app/assets/javascripts/vendor/react-modal-v1.0.0.jsjs //= require react //= require ./vendor/react-modal-v1.0.0ReactModalvariable in my code:js // inside a component definition: render: function() { return ( <div> <ReactModal /> </div> ) }