Installations
npm install @jhessin/react-hyperscript-helpers
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
9.5.0
NPM Version
3.10.10
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (81.47%)
TypeScript (18.53%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
jhessin
Download Statistics
Total Downloads
659
Last Day
2
Last Week
4
Last Month
9
Last Year
103
GitHub Statistics
51 Commits
1 Watching
2 Branches
1 Contributors
Bundle Size
3.46 kB
Minified
1.56 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.2.0
Package Id
@jhessin/react-hyperscript-helpers@1.2.0
Size
31.00 kB
NPM Version
3.10.10
Node Version
9.5.0
Total Downloads
Cumulative downloads
Total Downloads
659
Last day
0%
2
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
350%
9
Compared to previous month
Last year
-24.3%
103
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
react-hyperscript-helpers
NOTE: This project is a fork of Jador's work Jador's work. It uses an arrayless syntax to avoid excessive brackets.
A library inspired by hyperscript-helpers and react-hyperscript.
Allows for expressing UIs in the hyperscript-helpers style but with first class support for React.
The api has been greatly improved, making the library usable for actual projects.
Why?
Pros
- Consistent javascript syntax
- Mistyped components return errors
- No need to litter code with
null
values when a component doesn't have any props - No need for a JSX syntax highlighter
- No need for a JSX linter
- JSX elements are just functions anyway
Cons
- Most react documentation is written with JSX so it might be unfamiliar syntax
- A lot of library components use JSX, so unless the compiled version of the library is used a JSX transform will be necessary
API
For elements that have already been compiled by hh
:
1tagName(selector); 2tagName(props); 3tagName(...children); 4tagName(props, ...children); 5tagName(selector, ...children); 6tagName(selector, props, ...children);
For custom components or tags not compiled by hh
:
1import { h } from 'react-hyperscript-helpers'; 2 3h(component, selector); 4h(component, props); 5h(component, ...children); 6h(component, props, ...children); 7h(component, selector, ...children); 8h(component, selector, props, ...children);
component
is an HTML element as a string or a react function/class custom elementselector
is a string, starting with "." or "#"props
is an object of attributes (the props of the component)children
is the innerHTML text (string|boolean|number), or an array of elements
Usage
DOM components are really easy to use. Just import and go.
1import { div, h2 } from 'react-hyperscript-helpers'; 2 3export default () => div('.foo', h2('Hello, world'));
For custom components you can either create a factory function or use the h
function, similar to react-hyperscript.
1//MyComponent 2import { div, hh } from 'react-hyperscript-helpers'; 3 4export default hh(() => div('Nifty Component')); 5 6//Container 7import MyComponent from './MyComponent'; 8import SomeOtherComponent from 'who-whats-its'; 9import { div, h } from 'react-hyperscript-helpers'; 10 11export default () => div('.foo', 12 MyComponent(), 13 h(SomeOtherComponent, { foo: 'bar' }) 14);
isRendered
The isRendered
property will determine whether or not a react component gets rendered.
1const Khaled = ({ display }) => ( 2 div({ isRendered: display }, 3 span('Another one'), 4 span('Another one'), 5 span('Another one'), 6 ); 7); 8 9h(Khaled, { display: false }); 10// -> null 11 12h(Khaled, { display: true }); 13/* -> 14 <div> 15 <span>Another one</span> 16 <span>Another one</span> 17 <span>Another one</span> 18 </div> 19*/
Alternatives
- https://github.com/uber/r-dom
- https://github.com/ohanhi/hyperscript-helpers
- https://github.com/mlmorg/react-hyperscript
References
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: ISC License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
53 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-hr2v-3952-633q
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr
- Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Score
1.7
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More