Skip to content

Commit

Permalink
fix(Spacing): rm mutation props (#7470)
Browse files Browse the repository at this point in the history
- see #6920

---

> Mutating component props or hook arguments is not allowed

Убираем мутации пропов, так как это не поддерживается реакт компилятором
  • Loading branch information
SevereCloud authored Aug 30, 2024
1 parent bbd6c3b commit e937999
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions packages/vkui/src/components/Spacing/Spacing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,18 @@ export interface SpacingProps extends HTMLAttributesWithRootRef<HTMLDivElement>
/**
* @see https://vkcom.github.io/VKUI/#/Spacing
*/
export const Spacing = ({
size = 'm',
style,
className,
...restProps
}: SpacingProps): React.ReactNode => {
if (typeof size === 'string') {
className = className ? classNames(sizesClassNames[size], className) : sizesClassNames[size];
} else {
if (style) {
// @ts-expect-error: TS7053 В React.CSSProperties не учитывается Custom Properties
style[CUSTOM_CSS_TOKEN_FOR_USER_GAP] = size;
} else {
// @ts-expect-error: TS2353 В React.CSSProperties не учитывается Custom Properties
style = { [CUSTOM_CSS_TOKEN_FOR_USER_GAP]: size };
}
}

export const Spacing = ({ size = 'm', style, ...restProps }: SpacingProps): React.ReactNode => {
return (
<RootComponent
{...restProps}
style={style}
className={className}
baseClassName={styles['Spacing']}
style={{
...(typeof size === 'number' && { [CUSTOM_CSS_TOKEN_FOR_USER_GAP]: size }),
...style,
}}
baseClassName={classNames(
styles['Spacing'],
typeof size === 'string' && sizesClassNames[size],
)}
/>
);
};

0 comments on commit e937999

Please sign in to comment.