import * as React from 'react'; import { injectPropsClick, updateProps } from '../click/propsClick'; export default function injectTaro() { const proto = React.Component.prototype; if (!proto.componentDidMount) { proto.componentDidMount = function () {}; } proto.componentDidMount = new Proxy(proto.componentDidMount, { apply: (target, thisArgument, argumentsList) => { const result: any = Reflect.apply(target, thisArgument, argumentsList); try { // 判定是否为 Taro 实现的 _Clickable 组件 if (thisArgument.panResponder && thisArgument.getWxAppEvent) { // console.info(Object.keys(thisArgument.props)) injectPropsClick(thisArgument); updateProps(thisArgument); } } catch (e: any) { console.warn(e.message); } return result; }, }); if (!proto.componentDidUpdate) { proto.componentDidUpdate = function () {}; } proto.componentDidUpdate = new Proxy(proto.componentDidUpdate, { apply: (target, thisArgument, argumentsList) => { try { // 判定是否为 Taro 实现的 _Clickable 组件 if (thisArgument.panResponder && thisArgument.getWxAppEvent) { updateProps(thisArgument); } } catch (e: any) { console.warn(e.message); } return Reflect.apply(target, thisArgument, argumentsList); }, }); }