-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: React props errors #4692
fix: React props errors #4692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ const ExplorerButton = ({ | |
className, | ||
onClick, | ||
isCompact = true, | ||
}: ExplorerButtonProps): ReactElement => { | ||
}: ExplorerButtonProps): ReactElement | null => { | ||
if (!href) return null | ||
|
||
return isCompact ? ( | ||
<Tooltip title={title} placement="top"> | ||
<IconButton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import useChains, { useCurrentChain } from '@/hooks/useChains' | ||
import useSafeAddress from '@/hooks/useSafeAddress' | ||
import { useCallback, useEffect, type ReactElement } from 'react' | ||
import { Checkbox, Autocomplete, TextField, Chip } from '@mui/material' | ||
import { Checkbox, Autocomplete, TextField, Chip, Box } from '@mui/material' | ||
import type { ChainInfo } from '@safe-global/safe-gateway-typescript-sdk' | ||
import ChainIndicator from '../ChainIndicator' | ||
import css from './styles.module.css' | ||
|
@@ -138,12 +138,16 @@ const NetworkMultiSelector = ({ | |
></Chip> | ||
)) | ||
} | ||
renderOption={(props, chain, { selected }) => ( | ||
<li {...props} key={chain.chainId}> | ||
<Checkbox data-testid="network-checkbox" size="small" checked={selected} /> | ||
<ChainIndicator chainId={chain.chainId} inline /> | ||
</li> | ||
)} | ||
renderOption={(props, chain, { selected }) => { | ||
const { key, ...rest } = props | ||
|
||
return ( | ||
<Box component="li" key={key} {...rest}> | ||
<Checkbox data-testid="network-checkbox" size="small" checked={selected} /> | ||
<ChainIndicator chainId={chain.chainId} inline /> | ||
</Box> | ||
) | ||
}} | ||
getOptionLabel={(option) => option.chainName} | ||
getOptionDisabled={isOptionDisabled} | ||
renderInput={(params) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting the |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,11 +217,13 @@ const TxNonceForm = ({ nonce, recommendedNonce }: { nonce: string; recommendedNo | |
const isRecommendedNonce = option === recommendedNonce | ||
const isInitialPreviousNonce = option === previousNonces[0] | ||
|
||
const { key, ...rest } = props | ||
|
||
return ( | ||
<div key={option}> | ||
<div key={key}> | ||
{isRecommendedNonce && <NonceFormHeader>Recommended nonce</NonceFormHeader>} | ||
{isInitialPreviousNonce && <NonceFormHeader sx={{ pt: 3 }}>Replace existing</NonceFormHeader>} | ||
<NonceFormOption key={option} menuItemProps={props} nonce={option} /> | ||
<NonceFormOption menuItemProps={rest} nonce={option} /> | ||
</div> | ||
) | ||
}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,24 +80,7 @@ exports[`SettingsChange should display the SettingsChange component with newOwne | |
</span> | ||
<div | ||
class="MuiBox-root css-yjghm1" | ||
> | ||
<button | ||
aria-label="" | ||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1vbp2rr-MuiButtonBase-root-MuiIconButton-root" | ||
data-mui-internal-clone-element="true" | ||
data-testid="explorer-btn" | ||
rel="noreferrer" | ||
tabindex="0" | ||
target="_blank" | ||
type="button" | ||
> | ||
<mock-icon | ||
aria-hidden="" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-tqxw8e-MuiSvgIcon-root" | ||
focusable="false" | ||
/> | ||
</button> | ||
</div> | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -180,24 +163,7 @@ exports[`SettingsChange should display the SettingsChange component with newOwne | |
</span> | ||
<div | ||
class="MuiBox-root css-yjghm1" | ||
> | ||
<button | ||
aria-label="" | ||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1vbp2rr-MuiButtonBase-root-MuiIconButton-root" | ||
data-mui-internal-clone-element="true" | ||
data-testid="explorer-btn" | ||
rel="noreferrer" | ||
tabindex="0" | ||
target="_blank" | ||
type="button" | ||
> | ||
<mock-icon | ||
aria-hidden="" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-tqxw8e-MuiSvgIcon-root" | ||
focusable="false" | ||
/> | ||
</button> | ||
Comment on lines
-184
to
-199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not rendered anymore in the snapshot because we are not mocking the chain and with my change, the explorer link is not rendered anymore if there is no href |
||
</div> | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -288,24 +254,7 @@ exports[`SettingsChange should display the SettingsChange component with owner d | |
</span> | ||
<div | ||
class="MuiBox-root css-yjghm1" | ||
> | ||
<button | ||
aria-label="" | ||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1vbp2rr-MuiButtonBase-root-MuiIconButton-root" | ||
data-mui-internal-clone-element="true" | ||
data-testid="explorer-btn" | ||
rel="noreferrer" | ||
tabindex="0" | ||
target="_blank" | ||
type="button" | ||
> | ||
<mock-icon | ||
aria-hidden="" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-tqxw8e-MuiSvgIcon-root" | ||
focusable="false" | ||
/> | ||
</button> | ||
</div> | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of destructuring to extract
key
fromprops
is unnecessary askey
is not needed for the child components. Remove destructuring and passprops
directly:return (<Typography {...props} data-testid="address-item" ...>
This keeps the code concise and aligned with best practices.