Permalink
Browse files

setting up React

  • Loading branch information...
ejdraper committed Jan 6, 2018
1 parent 943e520 commit 771fce6b9419097eee3bec5cc8523bf31dad76bf
Showing with 201 additions and 15 deletions.
  1. +18 −10 .babelrc
  2. +26 −0 app/javascript/packs/hello_react.jsx
  3. +1 −1 app/views/layouts/application.html.erb
  4. +4 −0 package.json
  5. +152 −4 yarn.lock
@@ -1,18 +1,26 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
],
"react"
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
["transform-class-properties", { "spec": true }]
[
"transform-class-properties",
{
"spec": true
}
]
]
}
@@ -0,0 +1,26 @@
// Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
// like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
// of the page.
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: 'David'
}
Hello.propTypes = {
name: PropTypes.string
}
document.addEventListener('DOMContentLoaded', () => {
ReactDOM.render(
<Hello name="React" />,
document.body.appendChild(document.createElement('div')),
)
})
@@ -6,7 +6,7 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'hello_vue' %>
<%= javascript_pack_tag 'application', 'hello_vue', 'hello_react' %>
</head>
<body>
@@ -3,7 +3,11 @@
"private": true,
"dependencies": {
"@rails/webpacker": "^3.2.0",
"babel-preset-react": "^6.24.1",
"coffeescript": "1.12.7",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"vue": "^2.5.13",
"vue-loader": "^13.6.2",
"vue-template-compiler": "^2.5.13"
156 yarn.lock

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 771fce6

Please sign in to comment.