UNPKG
@pmwcs/base
Version:
latest (1.1.0)
next (1.0.0-2)
1.1.0
1.0.2
1.0.1
1.0.0
1.0.0-2
1.0.0-1
PMWCS base module
github.com/pmwcs/pmwcs
pmwcs/pmwcs
@pmwcs/base
/
next
/
utils
/
hooks.js
7 lines
•
236 B
JavaScript
View Raw
1
2
3
4
5
6
7
import
{ useState }
from
'preact/hooks'
;
import
{ randomId }
from
'./random-id'
;
export
const
useId =
function
(
prefix, props
) {
const
idToUse = props.
id
? props.
id
:
randomId
(prefix);
const
[id] =
useState
(idToUse);
return
id; };