— General, React, Ruby, Rails — 1 min read
This week consisted of regular expressions, recursion, a hash table lesson, rails basics, another lesson on graphs, and a how-to on hooking up Rails to React.
Interested in the exact steps to create a React app that talks to your Rails app? You've come to the right place.
Here goes:
1create-react-app client
1gem install foreman
1touch Procfile
1web: cd client && npm start2api: bundle exec rails s -p 3001
1foreman start -p 3000
At this point, both of your servers should load - open up localhost:3000 and localhost:3001.
Working? Great. Now quit out of your servers.
In client/package.json, add a proxy:
1"proxy": "http://localhost:3001/"
1foreman start -p 3000