react-minimalistic-use-form
Version:
Minimalistic react hook for handling forms without much pain.
30 lines • 920 B
JavaScript
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import { useEffect, useState } from 'react';
export var useIsUpdated = function (method, props) {
var _a = __read(useState(false), 2), hasRun = _a[0], setHasRun = _a[1];
useEffect(function () {
if (hasRun) {
method();
}
else {
setHasRun(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, props);
};
//# sourceMappingURL=is-updated.js.map