Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Convert HTML attribute names to React props

License

Notifications You must be signed in to change notification settings

hatashiro/react-attr-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 🍻

License

MIT

About

Convert HTML attribute names to React props

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published