zmp-react
Version:
Build full featured iOS & Android apps using ZMP & React
38 lines (29 loc) • 892 B
JavaScript
;
exports.__esModule = true;
exports.useSmartSelect = void 0;
var _react = require("react");
var _zmp = require("./zmp");
var _utils = require("./utils");
var useSmartSelect = function useSmartSelect(smartSelect, smartSelectParams, zmpSmartSelect, getEl) {
var onMount = function onMount() {
(0, _zmp.zmpready)(function () {
if (smartSelect) {
var ssParams = (0, _utils.extend)({
el: getEl()
}, smartSelectParams || {});
zmpSmartSelect.current = _zmp.zmp.smartSelect.create(ssParams);
}
});
};
var onDestroy = function onDestroy() {
if (zmpSmartSelect.current && zmpSmartSelect.current.destroy) {
zmpSmartSelect.current.destroy();
}
zmpSmartSelect.current = null;
};
(0, _react.useEffect)(function () {
onMount();
return onDestroy;
});
};
exports.useSmartSelect = useSmartSelect;