Skip to content

Commit

Permalink
fix: annotation with rollup conflict (react-component#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
condorheroblog committed Jan 16, 2024
1 parent f251058 commit c761c75
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/validateUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}
Expand Down

0 comments on commit c761c75

Please sign in to comment.