reactjs/react-rails

ReactRailsUjs.components is empty

TB-Development opened this issue · 2 comments

Expected behavior

I want the react component to render content on the screen

Actual behavior

Components are not mounting at all. There is no response from componentDidMount() react function inside the component, but I see the component on the screen, but with nothing that the render call would print.

System configuration

Ruby: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
Rails: 4.2.11.3
Webpacker: 4.3.0
Sprockets: 3.7.2
Node: v14.21.3
Yarn: 1.22.19
react-rails: 2.6.2


I'm working on integrating React into Rails using webpacker. Webpacker is responsible for only React in this application, sprockets will load the rest. I've recently upgraded to Rails 4.2.11.3 from the latest version of Rails 3. Rails 3 doesn't support Webpacker, and there are ES6 issues with Sprockets and React, so I've decided it's best to use Webpacker to manage React.

I've followed several tutorials in setting up React with Webpacker, this is the best one I've found .

Please reference this SO post for extra information

I'm not getting any console errors, but when I list the components that ReactRailsUjs has mounted, it returns {}. So I'm a bit confused here, why are the components not mounting? It seems like I've done everything the guides say.

Screen Shot 2023-04-18 at 3 47 34 PM
Screen Shot 2023-04-18 at 3 47 23 PM

May you create a public repo to demonstrate and reproduce the issue? This way, we can help more effectively, mainly since your setup uses outdated Rails and Webpacker.

@TB-Development May you please share some updates? Could you resolve the issue?

I close the issue for now. We can open it again if this issue persists and you can help us to reproduce it.