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

Mount/Render a React component manually using JS

I am trying to use the react-rails with the kaminari gem. below piece of code is responsible for creating the Admins page with pagination, paginate being a kaminari method: #app/views/dashboard/admins/_admins.html.erb
Vipin Verma
  • 5,330
  • 11
  • 50
  • 92
1
vote
2 answers

ReactCompositeComponent.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object

I am getting the above error in the console, even though I'm correctly returning the Component to be rendered. Value of errorTexts = ["email is invalid"] in the following code if(@state.errorTexts.length>0) dangerouslySetInnerHTML: { …
Vipin Verma
  • 5,330
  • 11
  • 50
  • 92
1
vote
4 answers

Heroku Production - ActionView::Template::Error (undefined method `directory' for #)

We have a react-rails app. Unfortunately, the app works on local development but not when deployed to heroku. When going to our default path on the app, we get the following error: ActionView::Template::Error (undefined method 'directory' for…
1
vote
2 answers

React Rails - Like button state not updating properly

What I have is a feed where you can post entries. These entries can then be liked by any user. The problem is that after you like an entry and continue with writing your own entry right after(thus pushing the new entry to the top of the feed) the…
lax1n
  • 59
  • 1
  • 8
1
vote
1 answer

Rails - React is not defined

First of all, this is not a duplicate! It's the same 'not defined' error but follows exactly the github (https://github.com/reactjs/react-rails) guide and still not working Gemfile: gem 'rails' gem 'pg', '~> 0.15' gem 'sass-rails' gem 'uglifier' gem…
Rares Mardare
  • 193
  • 1
  • 4
  • 13
1
vote
1 answer

React-rails: Component with { prerender: true } issue

I'm using the react-rails gem in a project. Whenever I pass in the {prerender: true} in react_component helper, I am getting this error : Encountered error "ReferenceError: ReactDOMServer is not defined" when prerendering UsersList with
Akshay Borade
  • 2,442
  • 12
  • 26
1
vote
0 answers

React: form building in a Rails-like way

I am trying to enhance an existing Rails application using React (react-rails gem). This app has a form built with following code: <%= form_for @article do |f| %>
<%= f.label :title %> <%= f.text_field :title %> …
Tsutomu
  • 4,848
  • 1
  • 46
  • 68
1
vote
1 answer

How can I manage reactjs component files in Rails, since the app now has so many reactjs components?

I'm using react-rails gem to work with Reactjs in my Rails application. Everything works well until the frontend becomes to have so many components which were defined in the separated file. The problem is every time the application was loaded, all…
Hieu Pham
  • 6,577
  • 2
  • 30
  • 50
1
vote
1 answer

How do I add React as a global whilst running unit tests?

In my Rails project, I am using the react-rails gem, which does the following: window.React = React; This is pretty handy, but when I run unit tests using Jest, that global is not there and I get an error from the file containing the component I am…
Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
1
vote
1 answer

Input field doesn't receive keyboard events when rendering with value property?

I am using react-rails gem to work with ReactJS for Rails. The weird thing is if I set a non-empty value property when rendering React component, the input field won't receive any keyboard event This doesn't work! React.DOM.input type: 'text' …
Hieu Pham
  • 6,577
  • 2
  • 30
  • 50
1
vote
0 answers

'cannot resolve file or directory "react"', with react-rails gem and rubymine

I am using react-rails gem and Rubymine. After rails g react:install, my application.js file looks like this: //= require jquery //= require jquery_ujs //= require turbolinks //= require react //= require react_ujs //= require components //=…
JackyJohnson
  • 3,106
  • 3
  • 28
  • 35
1
vote
0 answers

How to transpile harmony for server side react rails

I am using react-rails, and I'm trying to render server side using the prerender option: <%= react_component('MyComponent', @data, {prerender: true}) %> When I do this, I get an error as a result of const: Exception: SyntaxError: Unexpected keyword…
Sam Lee
  • 9,913
  • 15
  • 48
  • 56
1
vote
2 answers

React-Rails: Load initial array state with ajax

I've been following along some tutorials with React and i'm starting out building an application on my own. I've come across a situation regarding components and i'm wondering if theres a best practice for this scenario. Please note, I'm just using…
Jshoe523
  • 3,851
  • 2
  • 18
  • 21
1
vote
1 answer

React-rails : Map multiple props

I am just starting with the react-rails gem, and here is my below code that i need help. My _mounts.js.jsx, var Mounts = React.createClass({ render () { var showMounts = (mount, details) =>
Preethi Kumar
  • 1,371
  • 1
  • 9
  • 16
1
vote
1 answer

Rails - React Router not keeping its props.children

I am trying to set up a React Router in Rails for the first time. The links on the router works and changes the hash as expected, but it does not render. I have narrowed down the issue with debugger, and find the following: MyRoutes (line 22,…
ec88
  • 11
  • 3