Can we have a blog post on migrating from react-on-rails to react-rails
See original GitHub issueSteps to reproduce
While migrating from react-on-rails to react-rails, I have transferred the same folder structure in App/Javascript While other configurations are okay, and web pack is successfully compiled
Expected behavior
The component should be rendered
Actual behavior
ReferenceError: CandidateExam is not defined
Folder Structure:
app/javascript --
--components
--CandidateExam
--actions
--api
--components
--containers
--helpers
--reducers
ajax.js
constants.js
--packs
application.js
System configuration
- ruby: 2.3.3
- ‘rails’, ‘5.2.0’
- ‘webpacker’, ‘3.5’
- ‘react-rails’, ‘2.4.4’
- “react_ujs”: “^2.4.4”
Contains of application.js
var componentRequireContext = require.context("components", true)
var ReactRailsUJS = require("react_ujs")
I am calling this from my erb file
<%= javascript_pack_tag 'application' %>
<%= react_component("CandidateExam/containers/index") %>
This is what my server has to say
Processing by ExamController#index as HTML
Rendering exam/index.html.erb within layouts/application
[Webpacker] Compiling…
[Webpacker] Compiled all packs in /home/kreetiuser/dev/smart_recruit/public/packs
Rendered exam/index.html.erb within layouts/application (4588.9ms)
User Load (48.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1
Rendered layouts/_header.html.erb (108.7ms)
Rendered shared/_flash_messages.html.erb (0.8ms)
Rendered layouts/_footer.html.erb (0.7ms)
Completed 200 OK in 5167ms (Views: 5116.9ms | ActiveRecord: 48.4ms)
Also, there’s no guide to migrate from react-on-rails to react-rails while the vice-versa is flooded in the internet.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Migration from react-rails - ShakaCode
Migrate From react-rails. If you are using react-rails in your project, it is pretty simple to migrate to react_on_rails. Remove the 'react-rails' gem...
Read more >Creating a React, Rails and Vite App | by Chow Jia Ying
Head over to localhost:3000, and we would be able to see the articles in the database. Migrating from Webpacker. If you have an...
Read more >Advanced React integration #28 - rails/webpacker - GitHub
Hey. I think having a webpacker-react gem would be great for this level of integration. I think it's fine for Rails to keep...
Read more >How to Integrate React with Ruby on Rails - Sloboda Studio
Find the detailed tutorial on integrating React JS with Ruby on Rails application. Expert tips from our experienced React and Rails ...
Read more >React on Rails: Building a Simple App - Honeybadger.io
It's a trick we can use to force Rails to exhibit React code only. Get Honeybadger's best Ruby articles in your inbox. We...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As per the above discussion, we know the solution. Closing the issue.
Yep @ttanimichi beat me to it!
To expand, you specified the components directory in this line:
var componentRequireContext = require.context("
components", true)