Skip to content

Commit

Permalink
fix(Swatch): fix key props issue in nextjs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 19, 2023
1 parent 4ca9641 commit 6471070
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/color-swatch/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import React, { Fragment } from 'react';
import { HsvaColor, hexToHsva, color as handleColor, ColorResult } from '@uiw/color-convert';

export type SwatchPresetColor = { color: string; title?: string } | string;
export type SwatchRectRenderProps = {
key: string | number;
title: string;
color: string;
checked: boolean;
Expand Down Expand Up @@ -81,15 +80,14 @@ const Swatch = React.forwardRef<HTMLDivElement, SwatchProps>((props, ref) => {
const render =
rectRender &&
rectRender({
key: idx,
title,
color: background,
checked: !!checked,
style: { ...rectStyle, background },
onClick: (evn) => handleClick(background, evn),
});
if (render) {
return render;
return <Fragment key={idx}>{render}</Fragment>;
}
const child =
rectProps.children && React.isValidElement(rectProps.children)
Expand Down

0 comments on commit 6471070

Please sign in to comment.