Skip to content

Commit 705e09a

Browse files
committed
Refactor markdownComponents to use destructured componentProps for improved clarity and maintainability in rendering MotionComponents.
1 parent 1561585 commit 705e09a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/functions/markdownComponents.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ export default function markdownComponents({
3030
ClassAttributes<HTMLHeadingElement> & HTMLAttributes<HTMLHeadingElement> & ExtraProps
3131
> = (props) => {
3232
const { children, id, className } = props;
33+
const { node, ...componentProps } = props;
3334
switch (tag) {
3435
case "table":
3536
case "input":
3637
case "hr":
3738
case "img":
3839
return (
3940
<MotionComponent
40-
{...props}
41+
{...componentProps}
4142
key={`${tag}-${id}`}
4243
variants={className ? undefined : sentenceVariants}
4344
onAnimationComplete={onCharacterAnimationComplete}
@@ -48,7 +49,7 @@ export default function markdownComponents({
4849
case "tr":
4950
case "th":
5051
case "td":
51-
return <MotionComponent {...props}>{children}</MotionComponent>;
52+
return <MotionComponent {...componentProps}>{children}</MotionComponent>;
5253
case "p":
5354
return (
5455
<TypewriterItem
@@ -80,7 +81,7 @@ export default function markdownComponents({
8081
dadElement={(children) => {
8182
if (Array.isArray(children)) {
8283
return (
83-
<MotionComponent {...props} key={`${tag}-${id}`} children={children} />
84+
<MotionComponent {...componentProps} key={`${tag}-${id}`} children={children} />
8485
);
8586
}
8687
return children;
@@ -97,7 +98,7 @@ export default function markdownComponents({
9798
dadElement={(children, isString) => {
9899
return (
99100
<MotionComponent
100-
{...props}
101+
{...componentProps}
101102
key={`${tag}-${id}`}
102103
variants={isString || className ? undefined : sentenceVariants}
103104
>

0 commit comments

Comments
 (0)