February 2019
Intermediate to advanced
240 pages
5h 25m
English
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( ... |