fix: avoid passing invalid to prop to DOM (#11931)
Fixed a React warning caused by the to prop being passed to the DOM when its value was undefined or false. Since to is not a valid HTML attribute, this triggered a console error. The prop is only used for styling logic, so I used Emotion’s shouldForwardProp to prevent it from being passed to the DOM, resolving the issue cleanly.  #11850 --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -1,12 +1,15 @@
|
|||||||
|
import isPropValid from '@emotion/is-prop-valid';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import { CardContent } from 'twenty-ui/layout';
|
|
||||||
import { IconChevronRight, IconComponent } from 'twenty-ui/display';
|
import { IconChevronRight, IconComponent } from 'twenty-ui/display';
|
||||||
|
import { CardContent } from 'twenty-ui/layout';
|
||||||
|
|
||||||
const StyledRow = styled(CardContent)<{ to?: boolean }>`
|
const StyledRow = styled(CardContent, {
|
||||||
|
shouldForwardProp: (prop) => prop !== 'to' && isPropValid(prop),
|
||||||
|
})<{ to?: boolean }>`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: ${({ onClick, to }) => (onClick || to ? 'pointer' : 'default')};
|
cursor: ${({ onClick, to }) => (onClick || to ? 'pointer' : 'default')};
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
Reference in New Issue
Block a user