react-nicknames
v1.0.0
Published
Rename HTML elements to a more JSX friendly format.
Downloads
2
Readme
Allows you to choose from a library of element names, or create your own to make your JSX more semantic.
Motivation
Inspired by this post on "div soup" and the efforts of polymer, this aims to make your JSX more understandable at a glance. As a bonus, the React inspector becomes a little more obvious and easier to search.
Usage
You can use any of the included names like a standard module or use the newNick
function to create one.
By default all elements will be <div>
s but you can change that by passing in an el
prop with an HTML element name.
eg:
import React from 'react'
import {Wrapper, Topbar, Button, newNick} from 'react-nicknames'
const CustomElement = newNick('CustomElement')
class MyApp extends React.Component {
render () {
return (
<Wrapper className="App">
<Topbar el="nav" className="Navigation">
<Button el="button" className="Button">
{'CLICK ME'}
</Button>
</Topbar>
<CustomElement onClick={someFunc} />
</Wrapper>
)
}
}
Will product a DOM that looks like:
<div class="App">
<nav class="Navigation">
<button class="Button">
{'CLICK ME'}
</button>
</nav>
<div onclick="someFunc"></div>
</div>
This is stupid
Probably, yeah, just use div soup.