From c761c7593e77f4ebb39c824041a3eabc31631b6c Mon Sep 17 00:00:00 2001 From: CondorHero Date: Tue, 16 Jan 2024 13:52:40 +0800 Subject: [PATCH] fix: annotation with rollup conflict (#631) --- src/utils/validateUtil.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/validateUtil.ts b/src/utils/validateUtil.ts index 866e0e85..28bb0684 100644 --- a/src/utils/validateUtil.ts +++ b/src/utils/validateUtil.ts @@ -79,10 +79,14 @@ async function validateRule( result = errObj.errors.map(({ message }, index: number) => { const mergedMessage = message === CODE_LOGIC_ERROR ? messages.default : message; - return React.isValidElement(mergedMessage) - ? // Wrap ReactNode with `key` - React.cloneElement(mergedMessage, { key: `error_${index}` }) - : mergedMessage; + if (React.isValidElement(mergedMessage)) { + // Wrap ReactNode with `key` + // Annotation makes conflict with rollup + // ref https://github.com/react-component/field-form/issues/631 + const key = `error_${index}`; + React.cloneElement(mergedMessage, { key }); + } + return mergedMessage; }); } }