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
2 answers

webpack-dev-server compiling very slow in rails app

When I run bin/webpack-dev-server On a rails 5.1.7 application using react with react-rails gem, it can get stuck for more than 10-20 minutes with the message: ℹ 「wdm」: wait until bundle finished: /packs/js/application-5bc097626fe492d88e56.js My…
Gotey
  • 449
  • 4
  • 15
  • 41
1
vote
0 answers

Using renderToNodeStream with react-rails / webpacker

I'm working on an app using react-rails / webpacker, with a rails server and React frontend. On top of this, we are also using styled-components and have overwritten the existing ReactRailsUJS.serverRender method in the…
1
vote
0 answers

Element type is invalid when pre-rendering a component with react-rails in a erb view

I have the following two components in the folder javascript/components/cardlist/ which I am trying to render in a erb view in rails 5.1.7 CardList.js import React from "react" import PropTypes from "prop-types" import CardBlock from…
Gotey
  • 449
  • 4
  • 15
  • 41
1
vote
1 answer

React Rails Uncaught SyntaxError: Unexpected token '!'

I would like to know how to solve the following error: Uncaught SyntaxError: Unexpected token '!' The corresponding line is: return new !(function webpackMissingModule() { var e = new Error("Cannot find module 'leaflet'"); e.code =…
ipegasus
  • 14,796
  • 9
  • 52
  • 76
1
vote
0 answers

React Mentions TypeError: Cannot read property 'style' of undefined

I have recently installed the react-rails gem to replace an old react integration inside of my rails app. But it seems like it broke the "react-mentions" package in production. It still works fine in my local dev environnement. When I try to…
Benjamin
  • 521
  • 1
  • 8
  • 19
1
vote
1 answer

How can I pass children to a component in a slim template using react_rails

I'm using react_rails to render react components inside of a slim template in a Ruby on Rails application. Is there a way to pass children to a React component, where the children are rendered server-side in slim? Here is what I would ideally like…
GSto
  • 41,512
  • 37
  • 133
  • 184
1
vote
1 answer

current_user is nil and user_signed_in? returning false react-rails with devise

I have a rails 5.2 app that was originally built with Devise and plain old erb files. I could check current_user in the frontend and all that. Now I am trying to slowly move it to React frontend. I haven't changed any of my setup but my…
Coding Enthusiast
  • 3,865
  • 1
  • 27
  • 50
1
vote
1 answer

How should I approach adding a react front-end to a web app built with rails?

I have an app that I've built with ruby on rails in the backend with the front end being simple rails views. I'd like to add react to the front end to make it look nicer. I have read about using the react-rails gem, or creating a new react app and…
1
vote
1 answer

Trigger an action in another component through their parent in React

There are two components which has a parent, I would like to trigger one action in another component through their parent. So far I have tried this: _mevent_show.js.jsx (One of the component): gotoSearchPage() { …
Tjax
  • 323
  • 1
  • 5
  • 12
1
vote
1 answer

Webpack Compile: Cannot find module '@babel/preset-env' when deploy production

i use capistrano to deploy my rails project( Rails 6.0.0, Ruby 2.6.0) i get bellow log when start `bundle exec cap production deploy ERROR in ./app/javascript/packs/application.js Module build failed (from…
1
vote
1 answer

Capybara tests don't work, while actual app works fine. React front-end in Rails 5

Specs: Rails 5.2, Ruby 2.5.1, Yarn 1.91.1, React-Rails 2.6.0, selenium-webdriver 3.14, chromedriver 77, capybara gem 3.29 , Ubuntu 18.04 Issue: I created a questionnaire using react components in a Rails app which works when run in development mode.…
Randall Coding
  • 463
  • 5
  • 15
1
vote
2 answers

Can't pass props to IIFE in JSX

I'm trying to use react-rails to create a UI for an existing rails app. I want to make a dynamic todo list which is populated with data from my rails backend. I'm passing the tasks to the component through an erb tag provided by the gem…
iThompkins
  • 155
  • 1
  • 12
1
vote
1 answer

Creating a reusable Redux Wrapper

I am working on a RoR project that uses webpacker and react-rails. We are slowly moving away from haml to React. Because of this, each page we are doing react_component('page_to_render') We are also using Redux and I had been calling my component…
Rudenate3
  • 1,821
  • 2
  • 12
  • 13
1
vote
0 answers

Using storybook with react-rails?

I am trying to use storybook with react-rails If I install the reactjs project inside app/assets/javascripts/components I will have so many other files not related directly to the project ( stories and node_modules.. etc) Whats is the recommended…
simo
  • 23,342
  • 38
  • 121
  • 218
1
vote
0 answers

Where should I add ActionDispatch middleware for a Rails API which includes both Web views and API

I have an application which uses a React component to update the user profile. With a backend of Rails, I'm attempting to pass a flash message on the #update action which is connected to the Rails API that I built for the React frontend.…
Bryan
  • 274
  • 3
  • 9