react-hyperscript-wrapper
v0.1.1
Published
Wrap react component with hyperscript function
Downloads
20
Maintainers
Readme
react-hyperscript-wrapper
Wrap react component with hyperscript function. Let write react without jsx style and display clearly.
Inspire by react-hyperscript-helpers.
Feature
- Just js function.
- Don't need react transpiler.
- More clear.
- Dynamic arguments.
- Can use custom component.
Full Example
import React from 'react';
import {wrapper} from 'react-hyperscript-wrapper';
// Wrap react default component
let {div} = wrapper({div: 'div'});
let HelloBox = React.createClass({
_onClick: function () {
console.log('hello world!');
},
render: function () {
return (
div('#testId.testClass',
div('#child',
div({onClick: this._onClick}, 'Hello World!')
)
)
);
}
});
// Wrap custom component
let {WarpHelloBox} = wrapper({WarpHelloBox: HelloBox});
ReactDOM.render(
WarpHelloBox(),
document.getElementById('content')
);
Origin
import React from 'react';
let HelloBox = React.createClass({
_onClick: function () {
console.log('hello world!');
},
render: function () {
return (
<div id="testId" className="testClass">
<div id="child">
<div onClick={this._onClick}>'Hello World!'</div>
</div>
</div>
);
}
});
ReactDOM.render(
<HelloBox />,
document.getElementById('content')
);
API
wrapper(components' object)
- components' object:
key
is the component's name.value
is the react component.
Return the hyperscript object. key
is the component's name. value
is the hyperscript function.
This function has three arguments.
- identifies: The react component's
id
andclassName
which setting by css identify rule. - properties: The react component's properties.
- children: The react component's children.
Contribute
- Fork it.
- Create your feature-branch
git checkout -b your-new-feature-branch
- Commit your change
git commit -am 'Add new feature'
- Push to the branch
git push origin your-new-feature-branch
- Create new Pull Request with
develop
branch
License
The MIT License (MIT)
Copyright (c) 2016 Lee < [email protected] >
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.