Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

velements

1.0.1 • Public • Published

Virtual Elements

Minimalistic JSX elements that do not require React.

Create elements using JSX:

/* @jsx h */
const virtualDiv = <div id='my-div'><p>text</p></div>;

Or in plain JavaScript:

const virtualDiv = h('div', { id: 'my-div' }, h('p', null, 'text'));

Convert it to a string:

const str = virtualDiv.toString();

Or use it in the browser:

document.getElementById('container').appendChild(virtualDiv.toElement());

The same objects can be used in React apps:

const reactElement = virtualDiv.toReactElement();
 
ReactDOM.render(reactElement, document.getElementById('container'));
 
const customReactFunc = (props) =>
{
    /* ... */
    return virtualDiv.toReactElement();
}

install

npm i velements

Downloadsweekly downloads

0

version

1.0.1

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability