Questions tagged [react-on-rails]
112 questions
28
votes
1 answer
Rails pre-compile dying on 3MB react file
We are using React on Rails within our Rails app. When we deploy, asset pre-compilation takes ~20 minutes.
Based on the deploy logs, it appears as though most of this time is spent pre-compiling a 3.3MB javascript file. That file "app.js"…

Ben
- 15,010
- 11
- 58
- 90
19
votes
1 answer
Why is YAML.safe_load failing on a YAML alias?
I've a locale file in my Rails application that works fine with Rails, but when I tried to use it with react_on_rails rake task (rake react_on_rails:locale) I'm getting this error:
Psych::BadAlias: Unknown alias: item_attributes
I found that the…

Matt
- 5,328
- 2
- 30
- 43
12
votes
2 answers
'Yarn install' cause 'trouble with network connection'
yarn install v0.21.3
[1/4] Resolving packages...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with…

nuT707
- 1,543
- 4
- 17
- 27
10
votes
3 answers
ReactJS: Pass parameter from rails to react router to component
I am trying to pass a value from the render function to the component:
= react_component('App', props: {test: 'abc'}, prerender: false)
Routes.jsx
App.jsx (component)
class App extends React.Component {
render()…

Alex Jose
- 278
- 3
- 17
9
votes
1 answer
Why is my axios get call repeating over and over using React.useEffect?
I am using axios on a React w/ Hooks front end to make a get request to populate my react-google-maps/api GoogleMaps Marker components using seed data in my rails backend. When I let the rails server run, the server repeatedly makes this call.
The…

kykyi
- 375
- 4
- 10
8
votes
2 answers
React newbie: sharing state across unlinked components
I'm a React newbie trying to integrate React into a Rails site. I have a CommentForm component at the very top of the page/html, and a Comments component at the bottom of the same page. At present, both are rendered through React-On-Rails'…

PlankTon
- 12,443
- 16
- 84
- 153
8
votes
2 answers
TypeError: Cannot read property 'userAgent' of undefined
I am trying to integrate react-slick slider into my ReactJS application.
Its working as expected when I integrate it into a new demo app, but if I integrate it into my own application it throws an error.
I am using rails as backend.
When I try to…

Anish
- 558
- 3
- 10
- 33
7
votes
1 answer
How can i use Nested forms in ReactJS?
Consider this code snnipet:
<%= form_for @survey do |f| %>
<%= f.error_messages %>
<%= f.label :name %>
<%= f.text_field :name %>

Henry Samuel
- 71
- 2
5
votes
0 answers
Lazy loading/react-loadable in React-on-Rails
I want to lazy load all of my top-level components to improve load time. I am using react-on-rails to integrate React and Ruby on Rails. To render the components, I have to register them like so in registration.jsx:
import ReactOnRails from…

chloewlin
- 115
- 2
- 8
4
votes
0 answers
react on rails ReactOnRails::PrerenderError
I'm trying to turn on serverside-rendering on react-on-rails by:
<%= react_component("App", props: @props, prerender: true) %>
but I got this error:
ERROR in SERVER PRERENDERING
Encountered error: "uninitialized constant…

Moeen
- 414
- 2
- 8
4
votes
2 answers
How do I add a logout in React on Rails in a Hamburger menu, I'm a student, by the way
I'm using React on Rails and currently logging out using a ERB component. I'm creating a hamburger menu for the app and putting the logout in it. Currently it just sitting out in the opening using <%= link_to "Logout", destroy_user_session_path,…
user10839797
4
votes
1 answer
How to use Rails Url helper in Webpacker / React-rails in Rails 5.1
I am using web-packer with react-rails gem to build a online travel app. I am facing a problem of using Rails URL helper in my JSX view with server side rendering:
For example in my jsx…

channa ly
- 9,479
- 14
- 53
- 86
4
votes
0 answers
React on Rails with server side rendering
I created a site using React on Rails. It works perfectly fine, but I have not noticed that server side rendering is turned off, and I need it for SEO so I decided to turn it on. The thing is that now I get an error like this:
ERROR in SERVER…

mdmb
- 4,833
- 7
- 42
- 90
4
votes
2 answers
Redux Reducer that simply returns an action's value and not a state?
I have a Container, an actionsCreator, and a reducer. In the below code, what's enabling the Reducer to return action.text instead of an updated state object? I thought reducers had to always return states.
HelloWorldContainer.jsx
import {…

Matthew Hinea
- 1,872
- 19
- 31
3
votes
0 answers
webpacker stops working in react-on-rails app
I'm unable to push my app to heroku because I get the following error when I run
ruby ./bin/webpack-dev-server …

Hugo
- 2,073
- 6
- 23
- 46