Created
July 14, 2017 17:20
-
-
Save wdehaes/38f7f204d3535b2d8c71c98a15d26d13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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')), | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment