Explorar el Código

Feat: Install why-did-you-render to detect component updates #3221 (#7969)

### What problem does this PR solve?

Feat: Install why-did-you-render to detect component updates #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
tags/v0.19.1
balibabu hace 5 meses
padre
commit
02db995e94
No account linked to committer's email address

+ 14
- 0
web/package-lock.json Ver fichero

"@types/webpack-env": "^1.18.4", "@types/webpack-env": "^1.18.4",
"@umijs/lint": "^4.1.1", "@umijs/lint": "^4.1.1",
"@umijs/plugins": "^4.1.0", "@umijs/plugins": "^4.1.0",
"@welldone-software/why-did-you-render": "^8.0.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"html-loader": "^5.1.0", "html-loader": "^5.1.0",
"husky": "^9.0.11", "husky": "^9.0.11",
"@xtuc/long": "4.2.2" "@xtuc/long": "4.2.2"
} }
}, },
"node_modules/@welldone-software/why-did-you-render": {
"version": "8.0.3",
"resolved": "https://registry.npmmirror.com/@welldone-software/why-did-you-render/-/why-did-you-render-8.0.3.tgz",
"integrity": "sha512-bb5bKPMStYnocyTBVBu4UTegZdBqzV1mPhxc0UIV/S43KFUSRflux9gvzJfu2aM4EWLJ3egTvdjOi+viK+LKGA==",
"dev": true,
"license": "MIT",
"dependencies": {
"lodash": "^4"
},
"peerDependencies": {
"react": "^18"
}
},
"node_modules/@xmldom/xmldom": { "node_modules/@xmldom/xmldom": {
"version": "0.8.10", "version": "0.8.10",
"resolved": "https://registry.npmmirror.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz", "resolved": "https://registry.npmmirror.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz",

+ 1
- 0
web/package.json Ver fichero

"@types/webpack-env": "^1.18.4", "@types/webpack-env": "^1.18.4",
"@umijs/lint": "^4.1.1", "@umijs/lint": "^4.1.1",
"@umijs/plugins": "^4.1.0", "@umijs/plugins": "^4.1.0",
"@welldone-software/why-did-you-render": "^8.0.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"html-loader": "^5.1.0", "html-loader": "^5.1.0",
"husky": "^9.0.11", "husky": "^9.0.11",

+ 9
- 0
web/src/app.tsx Ver fichero

de: deDE, de: deDE,
}; };


if (process.env.NODE_ENV === 'development') {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, {
trackAllPureComponents: true,
trackExtraHooks: [],
logOnDifferentValues: true,
});
}

const queryClient = new QueryClient(); const queryClient = new QueryClient();


type Locale = ConfigProviderProps['locale']; type Locale = ConfigProviderProps['locale'];

+ 5
- 2
web/src/components/ui/form.tsx Ver fichero

}; };
}; };


const FormItem = React.forwardRef<
const InnerFormItem = React.forwardRef<
HTMLDivElement, HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => { >(({ className, ...props }, ref) => {
</FormItemContext.Provider> </FormItemContext.Provider>
); );
}); });
FormItem.displayName = 'FormItem';

InnerFormItem.displayName = 'FormItem';

const FormItem = React.memo(InnerFormItem);


const FormLabel = React.forwardRef< const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>, React.ElementRef<typeof LabelPrimitive.Root>,

+ 4
- 0
web/src/components/ui/input.tsx Ver fichero

); );
}); });


if (process.env.NODE_ENV !== 'production') {
InnerBlurInput.whyDidYouRender = true;
}

export const BlurInput = React.memo(InnerBlurInput); export const BlurInput = React.memo(InnerBlurInput);


export { ExpandedInput, Input, SearchInput }; export { ExpandedInput, Input, SearchInput };

+ 7
- 4
web/src/pages/agent/form/categorize-form/dynamic-categorize.tsx Ver fichero

FormLabel, FormLabel,
FormMessage, FormMessage,
} from '@/components/ui/form'; } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { BlurInput, Input } from '@/components/ui/input';
import { BlurTextarea } from '@/components/ui/textarea'; import { BlurTextarea } from '@/components/ui/textarea';
import { useTranslate } from '@/hooks/common-hooks'; import { useTranslate } from '@/hooks/common-hooks';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
x !== form.getValues(`${formListName}.${index}.${latestField}`), x !== form.getValues(`${formListName}.${index}.${latestField}`),
); );


const NameInput = ({
const InnerNameInput = ({
value, value,
onChange, onChange,
otherNames, otherNames,
); );
}; };


const NameInput = memo(InnerNameInput);

const InnerFormSet = ({ nodeId, index }: IProps & { index: number }) => { const InnerFormSet = ({ nodeId, index }: IProps & { index: number }) => {
const form = useFormContext(); const form = useFormContext();
const { t } = useTranslate('flow'); const { t } = useTranslate('flow');
<FormItem> <FormItem>
<FormLabel>{t('categoryName')}</FormLabel> <FormLabel>{t('categoryName')}</FormLabel>
<FormControl> <FormControl>
<NameInput
<BlurInput {...field}></BlurInput>
{/* <NameInput
{...field} {...field}
otherNames={getOtherFieldValues(form, 'items', index, 'name')} otherNames={getOtherFieldValues(form, 'items', index, 'name')}
validate={(error?: string) => { validate={(error?: string) => {
form.clearErrors(fieldName); form.clearErrors(fieldName);
} }
}} }}
></NameInput>
></NameInput> */}
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

Cargando…
Cancelar
Guardar