Skip to Content
Docker for Rails Developers
book

Docker for Rails Developers

by Rob Isenberg
February 2019
Intermediate to advanced
240 pages
5h 25m
English
Pragmatic Bookshelf
Content preview from Docker for Rails Developers

A Hello World React App

Our purpose here is to ensure we can configure our Rails app, using Docker, to allow us to develop modern JavaScript apps using technologies like React. To that end, we just need to show that a simple React app is compiled and loads correctly with our setup.

When we install Webpacker, it adds a sample “Hello World” React app in app/javascript/packs/hello_react.jsx that renders a <div> saying “Hello React!”:

 import React from 'react'
 import ReactDOM from 'react-dom'
 import PropTypes from 'prop-types'
 
 const Hello = props => (
  <div>Hello {props.name}!</div>
 )
 
 Hello.defaultProps = {
  name: 'World'
 }
 Hello.propTypes = {
  name: PropTypes.string
 }
 
 document.addEventListener('DOMContentLoaded', () => {
  ReactDOM.render( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Adam Notodikromo
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao

Publisher Resources

ISBN: 9781680506730Errata Page