app-base-react
Version:
react development common base package.
1 lines • 587 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),_utils=require("./utils"),Watcher=function(t){var e=t.watchKey,r=t.watch,c=t.formData,a=t.firstMount,i=(0,_utils.getValueByPath)(c,e),n=r[e];return(0,_react.useEffect)(function(){function t(){if("function"==typeof n)try{n(i)}catch(t){console.log(e+"对应的watch函数执行报错:",t)}else if(n&&"function"==typeof n.handler)try{n.handler(i)}catch(t){console.log(e+"对应的watch函数执行报错:",t)}}(!a||n&&n.immediate)&&t()},[JSON.stringify(i),a]),null};exports.default=Watcher;