are-message
Version:
This is a React global notification message component. It is a standalone implementation of the are-visual message component.
28 lines (22 loc) • 506 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useGenId;
var _react = require("react");
var _types = require("../types/types");
function genId(value) {
if ((0, _types.isTruthy)(value)) {
return value;
}
return null;
}
function useGenId() {
var index = (0, _react.useRef)(0);
var gen = (0, _react.useCallback)(function (value) {
index.current += 1;
var id = genId(value) || index.current;
return id;
}, []);
return gen;
}