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.

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.