0.3.0 • Published 5 years ago
@sbovyrin/v-creator v0.3.0
v-creator.js
Create a view in functional way without using jsx.
! The library is under development
API
cv
cv(tag|ReactComponent [, {props} ])(children)
- Return a React element
tag
must be a stringReactComponent
must be a valid React elementprops
are optionalchildren
can be array of React elements or raw js data structures- !
children
will wrap in React.Fragment if passed as array and the array contains at least one valid React element.
Create a react element
VCreator.cv('h1')('Hello, World!');
Create a react element and pass prop
VCreator.cv('h1', {class: 'heading'})('Hello, World!');
Create a react element with multiple react elements within
VCreator.cv('div')([
VCreator.cv("h1")("Children 1"),
VCreator.cv("h2")("Children 2"),
// ...
])
Create a react element with multple raw js elements within
VCreator.cv('div')([
"children 1",
"children 2",
// ...
])
Using
CDN
<script src="https://unpkg.com/@sbovyrin/v-creator/umd/v-creator.min.js"></script>
CommonJS module
const VCreator = require('@sbovyrin/v-creator')
ES module
import VCreator from '@sbovyrin/v-creator'