DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Clean Up Your Props with JavaScript Destructuring

Are you tired of writing props.user.name and props.data.id repeatedly inside your modern JavaScript or React components? Embrace destructuring! Instead of taking the whole props object and drilling down, immediately pull out the variables you need right in the function signature. For example: const MyComponent = ({ user, isLoading }) => { ... }. This makes your code much cleaner, easier to read, and immediately shows developers exactly which pieces of data your component relies on without having to check the component body.

Top comments (0)