Hyperloop Brings React and Ruby Together

Ruby on Rails

Hyperloop is a great approach for Ruby developers who want to use React but aren’t willing to spend a lot of time learning and mastering JavaScript. I have always liked Ruby and a language so I can imagine if I spent several years working in Ruby that I wouldn’t want to have to split my time between writing Ruby on the backend and then JavaScript on the frontend. So while I won’t be using Hyperloop, I think it could be great for Ruby devs. Although, the translation from Ruby to JavaScript could be tricky and/or cause compatibility issues in the future. Looking at the Get Started guide, I do like the elegance of writing Ruby code to implement React components:

class HelloWorld < React::Component::Base
  param :time, type: Time
  render do
    p do
      span { "Hello, " }
      input(type: :text, placeholder: "Your Name Here")
      span { "! It is #{params.time}"}
    end
  end
end

every(1) do
  Element["#example"].render do
    HelloWorld(time: Time.now)
  end
end

They have a bunch of great tutorials and one of the first ones I wanted to look at was how life-cycle methods are implemented. They changed things a bit and went with before_mount, after_mount, after_udpate instead of componentWillMount, componentDidMount and componentDidUpdate. Not exactly sure why they changed the methods.

Again, interesting concept and great for existing Ruby devs.