Allows you to choose from a library of element names, or create your own to make your JSX more semantic.
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.
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>
Probably, yeah, just use div soup.