tag-hoc
React HOC to set an element's tag and remove props
Last updated 9 years ago by jxnblk .
MIT · Original npm · Tarball · package.json
$ cnpm install tag-hoc 
SYNC missed versions from official npm registry.

tag-hoc

React HOC to set an element's tag and remove props

Useful for removing style props in libraries like styled-components

npm i tag-hoc

Usage

// 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(
  <Title
    is='h1'
    color='tomato'>
    Hello
  </Title>
)

This renders an <h1> element with the is and color props stripped from the HTML.

MIT License

Current Tags

  • 1.0.0                                ...           latest (9 years ago)

2 Versions

  • 1.0.0                                ...           9 years ago
  • 1.0.0-0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (13)

Copyright 2013 - present © cnpmjs.org | Home |