0 day streak
javascript / beginner
Snippet

Concise Components with Arrow Functions

Arrow functions provide a shorter syntax for writing functions. They are frequently used for functional components that primarily return JSX without complex logic.

snippet.js
javascript
1
2
3
4
5
6
7
const Header = () => (
<header>
<h1>My Next.js App</h1>
</header>
);
export default Header;
nextjs
Breakdown
1
const Header = () => ...
Declares a constant variable and assigns it an anonymous function with an implicit return.