Skip to content

making thunk work #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
mustmodify opened this issue Oct 25, 2017 · 5 comments
Closed
1 of 4 tasks

making thunk work #818

mustmodify opened this issue Oct 25, 2017 · 5 comments

Comments

@mustmodify
Copy link

mustmodify commented Oct 25, 2017

Help us help you! Please choose one:

  • My app crashes with react-rails, so I've included the stack trace and the exact steps which make it crash.
  • My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior.
  • I'm trying to use react-rails with another library, but I'm having trouble. I've described my JavaScript management setup (eg, Sprockets, Webpack...), how I'm trying to use this other library, and why it's not working.
  • I have another issue to discuss.

This doesn't EXACTLY fit under my other ticket (#813) about a discussion of the asset pipeline vs npm but you might find some inspriation here for that content.

Due to a ton of dependency issues, I'm currently stuck with Rails 3.2 and react-rails 0.13.0.0.

I want to add redux.

I tried looking for a gem that had it. No luck. Again, dependency issues. I have another rails app working with react-on-rails, but due to my current ruby version on this app, I guess that's a non-starter. So I need something that isn't gem-or-ruby dependent.

In a last-ditch effort to avoid more infrastructure on the server (node, etc) I am trying to include redux via a CDN:

=javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/redux/3.7.2/redux.min
.js'

but in my js files, which are included after that, I don't have access to applyMiddleware or createStore. In my react-on-rails app, I must import everything; but whenever I try that, I get:

Error: Parse Error: Line 1: Illegal import declaration

so, am I stuck? I guess I must use NPM? Why can't I use import? Why can't I get access to thunk? It should be available...

@BookOfGreg
Copy link
Member

I assume you are using Sprockets.
What dependency is stopping you go from React-rails 0.13 to 2.4?

I'll try spin up a version of my example app with redux and see if I can get it going.

I just started a quick google along the lines of sprockets redux and came across this blogpost using Rails 3.2 + react-rails + redux so I'm hopeful I should be able to help you with this soon.

http://www.lampesberger.net/blog/2016/03/16/react-slash-redux-with-rails-3-dot-2-and-sprockets/

@BookOfGreg
Copy link
Member

I only recently realised that recent versions of Sprockets actually load in node_modules, would it help you to yarn add redux and load it in your app.js?

@mustmodify
Copy link
Author

So I now have react-rails 2.4.4 working... not sure why it wasn't that way in the Gemfile before.

So now it's:
rails: 3.2.13
react_rails 2.4.4
ruby: 2.2.9

According to the instructions, I should be able to:

$ bundle install
$ bundle exec rake webpacker:install
$ bundle exec rake webpacker:install:react
$ rails generate react:install

Turns out webpacker requires rails >= 4.2, so I'll have to configure webpacker myself or use react_on_rails, which is working for another Rails 3.2 app. What should I do? Manual or switch to react_on_rails?

@BookOfGreg
Copy link
Member

BookOfGreg commented Mar 23, 2018

http://guides.rubyonrails.org/maintenance_policy.html
Rails 3.x is now unsupported for even security fixes so I don't recommend anything that keeps you on that version. My preference would be upgrade to 4.2 and Webpacker. If React_on_rails supports Rails 3.2 then they aren't being very security minded.

react-rails as recently as v2.4.3 worked with Rails 3.2 on sprockets, you could use this with sprockets if you are locked back on other dependencies.
https://github.com/reactjs/react-rails#use-with-asset-pipeline

abfc1fc#diff-354f30a63fb0907d4ad57269548329e3L22

@alkesh26
Copy link
Collaborator

alkesh26 commented Nov 1, 2022

@mustmodify any updates from your side? Closing the issue now. Feel free to reopen this if you are still facing the problem.

@alkesh26 alkesh26 closed this as completed Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants