Created
April 22, 2016 02:01
-
-
Save interactivellama/c54750abdcaba4d77d95113062d1fd5f to your computer and use it in GitHub Desktop.
React component placeholder
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
// DO NOT USE THIS COMPONENT IN PRODUCTION | |
import React from 'react'; | |
// Removes the need for `PropTypes`. | |
const { PropTypes } = React; | |
// The component name will be used as the `DisplayName` and exported along with | |
// the component itself. | |
export const COMPONENT = 'ComponentPlaceholder'; | |
const ComponentPlaceholder = React.createClass({ | |
// ### Display Name | |
// Always use the canonical component name as the React display name. | |
displayName: COMPONENT, | |
// ### Prop Types | |
propTypes: { | |
children: PropTypes.node, | |
name: PropTypes.string, | |
properties: PropTypes.string, | |
}, | |
render () { | |
const html = this.props.name || '<div>' + this.constructor.displayName + '</div>' | |
// Intentionally going against conventional here: https://facebook.github.io/react/tips/dangerously-set-inner-html.html | |
return ( | |
<div style={{padding: '10px', border: '1px #CCC solid'}}> | |
<div dangerouslySetInnerHTML={{__html: html}}></div> | |
<div>{this.props.properties}</div> | |
{this.props.children} | |
</div> | |
); | |
} | |
}); | |
export default ComponentPlaceholder; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment