Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Heading React Component
import React from 'react'
import PropTypes from 'prop-types'
const Heading = ({children, cssClass, level}) => {
const Tag = `h${level}`
return <Tag className={cssClass}>{children}</Tag>
}
Heading.propTypes = {
children: PropTypes.node.isRequired,
level: PropTypes.number.isRequired,
cssClass: PropTypes.string
}
export default Heading
@hankchizljaw

This comment has been minimized.

Copy link
Owner Author

hankchizljaw commented Feb 17, 2020

Usage:

import Heading from './heading.js';

<Heading level={2}>Hello, I am a second level heading</Heading>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.