Comments (24)
I think it might be related to this issue: #11
Try setting config.react.variant = :development
in config/environments/development.rb
(and the corresponding in production, etc) and see if that helps.
from react-rails.
+1
from react-rails.
I will take a look at it when I'm back from skiing next week
from react-rails.
I run into this issue when precompiling assets for production. Yes, I have config.react.variant = :production
in my production.rb
.
from react-rails.
OK, so... I'm gonna tackle this on Monday.
In the meantime could you try this branch https://github.com/jakubmal/react-rails/tree/feature/react-dropin ? Just to prove it's not shady it's here as PR, awaiting some minor formal fixes.
You are including it inside a rails engine, would you mind if I asked for a little gist? @kjf @adtaylor @steadicat
from react-rails.
Oops, I missed the "inside rails engine" part. I'm using react-rails
the normal way (react-rails
in the the gemfile and line config.react.variant = :production
in production.rb
). Your branch did not fix it for me.
from react-rails.
@steadicat is your last message
Your branch did not fix it for me.
about usage inside rails engine, or not?
from react-rails.
@steadicat any more details? Rails version, ruby version, etc.
I'm not familiar with Rails engines... Can somebody having issues describe the minimum needed to repro?
from react-rails.
@zpao: Ruby 1.9.3, Rails 3.2.14.
@JakubMal: I'm not using an engine.
from react-rails.
@kjf you still there?
from react-rails.
@JakubMal Sorry, totally forgot about this issue. I'll throw up an example app later today that should highlight the issue.
from react-rails.
@kjf just making sure, you haven't forgotten...
@adtaylor maybe you could spare a moment for a repro case
from react-rails.
@JakubMal Apologies! Have been swamped.
This should highlight the issue: https://github.com/kjf/React-Rails-Engine
If you start your rails server and visit: http://localhost:3000/blorgh then you should see the exception Sprockets::FileNotFound thrown with the message "couldn't find file 'react'"
from react-rails.
Hi, no problem.
It is a combination of:
- Rails Engine architecture
- #11
I'm going to describe the steps I took to make this work, and if it's not enough for you, I could send you a working application.
Let's start with Rails Engine. Take a look at: http://stackoverflow.com/a/5850503/362830
Essentially, you need to load dependencies of your engine yourself.
Then comes the very unfortunate #11, react will not be added to assets, unless config.react.variant
is set. You will have to add an initializer, which will run before react_rails.setup_engine
. I could slightly help you here, and create a fork for you, variant
would come from Rails.env
unless otherwise defined.
As to when this fix could be in a main branch, not soon, but there are certain changes coming... I will let you know.
from react-rails.
@JakubMal Gotcha, had tried loading dependencies so it was #11 was tripping me up. Adding initialiser should do the job. Thanks for your help on this!
from react-rails.
I'm still having trouble with this, but I'm not using a Rails engine. I get couldn't find file 'react'
when running rake assets:precompile
. Should I file a separate issue?
from react-rails.
@steadicat separate issue, please 👍
@kjf do you think anything should be changed on react-rails' part? or is should we rather close this?
from react-rails.
@JakubMal I think everything is clear now. Close away and thanks again!
from react-rails.
Hi @JakubMal.
Sorry for opening this old ticket, but it's my problem exactly!
Regarding your answer:
Then comes the very unfortunate #11, react will not be added to assets, unless config.react.variant is set. You will have to add an initializer, which will run before react_rails.setup_engine. I could slightly help you here, and create a fork for you, variant would come from Rails.env unless otherwise defined.
I can't seem to get it to work with my engine setup.
Here's what I did. Inside lib/my_engine/engine.rb
module MyEngine
class Engine < ::Rails::Engine
initializer("my_engine.react-rails") do |app|
MyEngine::Engine.config.react.variant = :production
end
require 'react-rails'
# and more
When I load the Rails console and query:
irb(main):003:0> MyEngine::Engine.config.react
=> {:variant=>:production}
But loading it in application.js (app/assets/my_engine/application.js) doesn't work.
couldn't find file 'react'
Any help is appreciated.
from react-rails.
@5minpause Did you figure this out?
from react-rails.
No @JonCrawford, I didn't. I only found a (bad) workaround.
from react-rails.
for what it's worth, adding require react-rails
to my engine.rb
worked for me
from react-rails.
Same here. That did it. 👍
On Tue, Jul 28, 2015 at 11:17 AM Brett Jurgens [email protected]
wrote:
for what it's worth, adding require react-rails to my engine.rb worked
for me—
Reply to this email directly or view it on GitHub
#21 (comment).
from react-rails.
same problem here. solution is not merged into master?
from react-rails.
Related Issues (20)
- Import react_component but it' shown HOT 2
- compare/contrast and migration steps to react_on_rails HOT 5
- Component doesn't render on jsbundling-rails webpacker HOT 5
- Component not loading in rails app HOT 5
- react-rails v3.1.0 is broken HOT 1
- server_rendering.js not found following README HOT 8
- Re-organize documentations in docs folder
- server_rendering.js not found following README HOT 1
- How do I handle styling?
- esbuild HOT 1
- Error related to server_rendering.js not found with SSR HOT 3
- Setup StrictMode for components HOT 2
- get started docs r-r version HOT 1
- Rails 7.1 Renders Partial Header HOT 1
- Server side rendering `window` behaves differently than Node.js? HOT 4
- Issues with Loading React Component for Cuprite in Rails 7.1 HOT 1
- Hooks not working due to Invalid Hook Call HOT 3
- Move react_ujs to es module flow
- Error when use React component other than HelloWorld HOT 1
- Different order for React rendering / DOM ready event in Webkit with React 18 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-rails.