React-rails: componentDidMount not fired

Created on 4 Jul 2016  路  6Comments  路  Source: reactjs/react-rails

_My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior._

Hello,

Since I've fixed a prerender issue in #555, componentDidMount is not fired anymore...
I've also added a server_rendering.js file to fix another issue, who is:

  • added to server_renderer_options in application.rb,
  • precompiled in assets.rb

I don't understand where the problem come from, even if I set the prerender to false the componentDidMount is still not fired.

All 6 comments

Wow, so the components _do_ mount on the page, but the function is never called?

I have _no_ idea what it could be, so I just have the normal questions:

  • Are there any errors in the browser console?
  • Can you share the source of a component which doesn't fire componentDidMount on a fresh page load?

@tchret If you disabled prerender, I assume your component was rendered by Ajax call or something like that (not on first page load). You should add <script>ReactRailsUJS.mountComponents()</script> where you render component and make sure //= require react_ujs exists in application.js. I just faced this issue and get over it. Hope this help!

Did you find a solution??

@rmosolgo yes, it was a dumb mistake where I was 100% involved...
Sorry for the inconvenience

no problem, glad you found it!

What was the issue? I've stumbled upon this issue myself and really can't get past it...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okolomoets picture okolomoets  路  5Comments

chrismv48 picture chrismv48  路  3Comments

hugofloss picture hugofloss  路  4Comments

axhamre picture axhamre  路  3Comments

davidlormor picture davidlormor  路  3Comments