Questions tagged [react-rails]

Regarding React.js + Ruby on Rails, especially the `react-rails` gem.

react-rails is a Ruby gem for integrating React.js into a Ruby on Rails application. Topics include transforming JSX, mounting React components into Rails views, and rendering React components on the server. Learn more on Github: https://github.com/reactjs/react-rails.

282 questions
1
vote
1 answer

react-rails gem not working with to_json

Whenever I try to pass other options to to_json on a react_component helper it is parsed just as plain string to the react prop. <%= react_component "SelectableActivityLevel", phase: UserService.active_phase(@user).to_json(methods:…
João Paulo Motta
  • 3,765
  • 1
  • 19
  • 18
1
vote
1 answer

How do I add an action to a form in React-Rails?

I am building an app with react-rails. I am trying to add multiple forms to a single page by adding custom actions to the controller. In the past with pure rails I was able to do like so: <%= form_for @food, :url=>{:controller=>"dailies",…
PilotLite
  • 11
  • 3
1
vote
1 answer

Server side rendering with React-rails and Algolia

I'm trying to prerender my react app server side but I came accross a problem: as soon as I require('algoliasearch') I get ReferenceError: XMLHttpRequest is not defined I tried to use faux-jax to mock XMLHttpRequest but then I get TypeError: Cannot…
Nima Izadi
  • 996
  • 6
  • 18
1
vote
1 answer

ExecJS::RuntimeError Rails 4 using react-rails gem

I am getting an error when I startup my local server rails s Error message: compile ((execjs):6633:19): SyntaxError: [stdin]:5:10: unexpected . (ExecJS::RuntimeError) and line 6 in my application.html.erb is highlighted: <%= javascript_include_tag…
Cyzanfar
  • 6,997
  • 9
  • 43
  • 81
1
vote
2 answers

How can I use this React library with React-Rails

I came upon this: https://github.com/ssorallen/turbo-react And I like what it does, I am just a bit confused about how I use this code within my Rails project that currently uses the React-Rails gem I am mostly confused about where to put the code…
spitfire109
  • 9,651
  • 3
  • 20
  • 28
1
vote
1 answer

How to dynamically update react components on page after sidekiq job succeed

I have a sidekiq jobs in my rails application. And I have a few react components on my site. How can I make my rails app page automatically update after the sidekiq job succeeds?
Alex Antonov
  • 14,134
  • 7
  • 65
  • 142
1
vote
1 answer

react-rails with jbuilder doesn't work

I try to use react-rails with jbuilder. For example, I use this great sample app of react-rails and try to rewrite to use jbuilder as a json response using reference from this part in react-rails. These are the main rewrite parts: #…
jwako
  • 173
  • 2
  • 12
0
votes
0 answers

React rails gem server side rendering issue

I'd like to design email templates in react and render them in my rails application. I have installed react-rails gem and did the preliminary installation steps. i.e rails g react:install. I intend to use server-side rendering in a sidekiq-worker to…
Denn
  • 803
  • 9
  • 19
0
votes
0 answers

how to use server side rendering using 'react-rails', '~> 2.6.1' gem

<%= react_component("HelloWorld", { greeting: "Hello from react-rails." }, {prerender: true}) %>
0
votes
0 answers

Cannot find module in ruby on rails app using react-rails

I have a rails app where I’m trying to add packages a simple react-rails component to a view I have. I’m able to get the react component to load fine in my .erb view without the packages. The react component is in /app/javascript/components.…
0
votes
0 answers

How do I use react boot strap with react-rails for server side rendering

I have a rails app setup with react-rails and it is loading react pages to the server with server-side rendering. Now in order to speed up my development I need to add react-bootstrap to these components but I'm bit stuck have tried multiple options…
0
votes
0 answers

Rails/React CSS Style Rendering Issue

I'm building a card game application using Rails as by backend and React as my frontend. I'm using Rails 6.1.7.2 and Webpack to implement React. So far I have a Board component and a Game component. The Board component I've nested inside the Game…
0
votes
0 answers

React-rails gem cannot find component

I have my rails 6 app using asset pipeline. Now in one module, I want to integrate react and for that I installed webpacker. After rails webpacker:install and rails g react:install , I created one component in app/javascipt/components directory.…
Muhammad Ans
  • 157
  • 8
0
votes
0 answers

df bw react-rails gem and react-on-rails gem

What are the differences that make either gem preferable over other. The official gem is react-rails that can be used to pass controller instance variable to react component similar to react-on-rails. Both can use react-router-dom.
0
votes
1 answer

How can I use ERB inside a React component? [Rails 6]

I have a project on Rails 6. Started migrating it to React by using react-rails. However, there are still some components which I cannot migrate to React ATM due to time limitations. I want to be able to use the old component (partial) in my React…
gilish
  • 13
  • 3