- Published
- Author
- Sachin
#nextJs #TypeScript
Function Argument Deconstructing: Deconstructing function arguments can make your code cleaner and more readable.
Function Argument Deconstructing: Deconstructing function arguments can make your code cleaner and more readable.
Code
// Before deconstruction
const BlogPost = (props) => {
const { title, content, author } = props;
// Render blog post using props
return (
<div>
<h1>{props.title}</h1>
<p>{props.content}</p>
<p>Written by: {props.author}</p>
</div>
);
};
// After deconstruction
const BlogPost = ({ title, content, author }) => {
// Render blog post with title, content, and author
return (
<div>
<h1>{title}</h1>
<p>{content}</p>
<p>Written by: {author}</p>
</div>
);
};