mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 21:20:58 +00:00
29 lines
769 B
JavaScript
29 lines
769 B
JavaScript
'use client';
|
|
'use strict';
|
|
|
|
var React = require('react');
|
|
var useForceUpdate = require('../use-force-update/use-force-update.cjs');
|
|
|
|
function useMap(initialState) {
|
|
const mapRef = React.useRef(new Map(initialState));
|
|
const forceUpdate = useForceUpdate.useForceUpdate();
|
|
mapRef.current.set = (...args) => {
|
|
Map.prototype.set.apply(mapRef.current, args);
|
|
forceUpdate();
|
|
return mapRef.current;
|
|
};
|
|
mapRef.current.clear = (...args) => {
|
|
Map.prototype.clear.apply(mapRef.current, args);
|
|
forceUpdate();
|
|
};
|
|
mapRef.current.delete = (...args) => {
|
|
const res = Map.prototype.delete.apply(mapRef.current, args);
|
|
forceUpdate();
|
|
return res;
|
|
};
|
|
return mapRef.current;
|
|
}
|
|
|
|
exports.useMap = useMap;
|
|
//# sourceMappingURL=use-map.cjs.map
|