Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to use React with Rails - Talk at LRUG June 2017

How to use React with Rails - Talk at LRUG June 2017

A Talk by Hrishi Mittal on a few different ways of using React with Ruby on Rails. More details at - https://learnetto.com/lrug

hrishimittal

June 12, 2017
Tweet

Other Decks in Programming

Transcript

  1. How to use React with Rails Hrishi Mittal Founder and

    Teacher at Learnetto @hrishio [email protected] Slides at learnetto.com/lrug
  2. What I will cover in this talk 1. What is

    React? 2. Why use React? 3. How to use React with Rails
  3. React is an open-source JavaScript library for building User Interfaces

    Released by Facebook in 2013 https://facebook.github.io/react/
  4. React is to the modern frontend, as Rails is to

    the backend Simplicity + power + community momentum =
  5. Why react-rails gem? Works with Rails 3.2+ Can use with

    Rails asset pipeline OR With Webpack (via Webpacker gem)
  6. Other features Server-side rendering ES6 and Coffeescript support Choosing react

    builds for your environment Command line component generators
  7. When to use it Rails < 5.1 Good for quickly

    trying out React with Rails Don’t want to use Webpack
  8. Why react_on_rails gem? Works with Rails 4.2+ (old versions support

    3.2+) Native Javascript tooling by default Webpack, yarn, ES6 Doesn’t rely completely on the Rails asset pipeline No jQuery dependence
  9. Rails < 5.1 Want to use yarn and Webpack Want

    in-built support for React Router or Redux When to use it
  10. c. Using React with Rails 5.1+ Native support for yarn

    Native support for Webpack via webpacker gem
  11. How to use it Installation creates javascript packs directory: app/javascript/packs

    Create your React component files with a .jsx extension
  12. Rails API Standalone Rails API on the backend OR Standard

    Rails app with some API endpoints with JSON output
  13. Frontend React app Use Create React App (for easy start

    with zero setup) OR Plain React app
  14. Depends on your team Makes sense for medium-large companies with

    dedicated teams for backend and frontend
  15. Use Cross Origin Resource Sharing (CORS) OR proxy requests through

    a server like nginx. Running two apps is more work
  16. If you have/want dedicated teams for frontend and backend If

    you have tested React and are sure you want to use it If you don’t mind overhead of running two apps When to use it
  17. What we covered in this talk 1. What is React?

    2. Why use React? 3. How to use React with Rails
  18. Thanks! Hrishi Mittal Founder and Teacher at Learnetto @hrishio [email protected]

    Slides + Free React on Rails course at learnetto.com/lrug