React HOC to set an element's tag and remove props
npm install tag-hocReact HOC to set an element's tag and remove props
Useful for removing style props in libraries like styled-components
``sh`
npm i tag-hoc
`..jsx
// Example with styled-components
// import React from 'react'
// import { render } from 'react-dom'
// import styled from 'styled-components'
// import tag from 'tag-hoc'
const propsToRemove = [
'color'
]
const Tag = tag(propsToRemove)
const Base = Tag('h2')
const Title = styled(Base)
color: ${props => props.color};
Title.defaultProps = {
color: '#07c'
}
render(
This renders an
element with the is and color` props stripped from the HTML.MIT License