react-attr-converter
Convert HTML attribute names to React props
Last updated 9 years ago by noraesae .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install react-attr-converter 
SYNC missed versions from official npm registry.

react-attr-converter travis-ci

Convert HTML attribute names to React props.

Convert how?

It converts HTML attribute names into prop names used by React.

convert('class'); // => 'className'
convert('for'); // => 'htmlFor'
convert('onclick'); // => 'onClick'
convert('onCLICK'); // => 'onClick'

It bypasses attribute names which are not supported by React.

convert('data-hello'); // => 'data-hello'
convert('lovelive'); // => 'lovelive'

How to use

Install with NPM:

npm i --save react-attr-converter

Import with CommonJS or whatever:

const convert = require('react-attr-converter');

import convert from 'react-attr-converter';
import * as convert from 'react-attr-converter'; // both of them work

A bug!

When a bug is found, please report them in Issues.

Also, any form of contribution(especially a PR) will absolutely be welcomed :beers:

License

MIT

Current Tags

  • 0.3.1                                ...           latest (9 years ago)

7 Versions

  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 7
This Month 7
Last Day 6
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |