2

Is it possible to render a react component in a rails partial through an AJAX call? Basically for performance reasons, I have to do some condition checks in order to render and initialize a react component in rails view. I cannot require the react JS upfront as well. I am thinking about rendering a partial through AJAX call and replacing the html in the view from jQuery. I am using react-rails for this purpose.

I'm not sure if this is the best way to do it. Other alternatives would be helpful too.

Pragun
  • 1,123
  • 8
  • 20

2 Answers2

2

checked react-rails source code and had to manually call ReactRailsUJS.handleMount() via javascript.

Pragun
  • 1,123
  • 8
  • 20
0

For me, calling ReactRailsUJS.mountComponents() fixed my issue.

daven97
  • 21
  • 1
  • 4