React on rails

Post on 21-Mar-2017

28 views 0 download

transcript

Alicia Guerra

React on Rails

Why Ruby?

Easy to learnObject-orientedRich LibrariesOpen source

Intro to Ruby on Rails

Server-side web application framework written in Ruby.

Configure your code with database schema.

Uses metaprogramming techniques to write programs.

Model-View-Controller in Ruby on Rails

A model maps to a table in a database and a Ruby file.

A controller is a server-side component that responds to external requests from the web server to the application.

A view is an erb file which is evaluated and converted to HTML at runtime.

Why should we use React with Rails?

Rails views can only take you so far.Plain erb/haml views with jQuery for the first few

dynamic features aren’t enough.The code will become unmaintainable and hard to

understand.

React.js

Leverages the virtual DOM for performance.Promotes componentized development. Just a view layer, so it helps make everything

more modular.Flux allows for unidirectional data flow.

react-rails gem

Simplest way to start using React inside your Rails app.It uses the default rails asset management and

automatically transforms Rails into the asset pipeline using the Ruby Babel transpiler.

Code organization is done very much the Rails way.

react_on_rails gem

Uses ES6 by default and state-of-the-art JavaScript tooling instead of relying on the Rails asset pipeline.

Doesn’t depend on jQuery.You can use npm to install JavaScript libraries.

Rails API with a Separate FrontEnd React App

Separate the frontend and backend into 2 different apps.

The backend can be either a standard Rails app exposing some API endpoints with JSON output or it can be a Rails API-only app.

Contact Me

Alicia GuerraEmail: alicia.developer@aliciaguerra.comTwitter: @skepchick92LinkedIn: linkedin.com/in/aliciaisabelguerra