Skip to content

Commit

Permalink
refactor: memoize callDataRow component
Browse files Browse the repository at this point in the history
  • Loading branch information
LordCheta committed Jan 14, 2025
1 parent 9f47946 commit 6d13c21
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/pages/proposals/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,22 @@ interface CalldataRowsData {
calldatasParsed: DecodedData[]
}

const CalldataRows = ({ calldatasParsed }: CalldataRowsData) => {
return (
<>
{calldatasParsed.map((callData, index) => (
<CalldataDisplay key={index} {...callData} />
))}
</>
)
}
const CalldataRows = React.memo(
({ calldatasParsed }: CalldataRowsData) => {
return (
<>
{calldatasParsed.map((callData, index) => (
<CalldataDisplay key={index} {...callData} />
))}
</>
)
},
(prevProps, nextProps) => {
return prevProps.calldatasParsed === nextProps.calldatasParsed
},
)

CalldataRows.displayName = 'CalldataRows' // For debugging purposes

const CalldataDisplay = ({
functionName,
Expand Down

0 comments on commit 6d13c21

Please sign in to comment.