DEV Community

Cover image for Adventofcode 🎄: Day 1 - React Components
Jemima M
Jemima M

Posted on

Adventofcode 🎄: Day 1 - React Components

Happy 1st of December developers! Each day of advent I will be writing a short/revision-like blog to help you along the way with React, and for Day 1 we will be talking about React Components.

React Components

Components serve as a self-contained and reusable building blocks of code, functioning independently. While sharing a similar purpose with JavaScript functions, components operate in isolation and produce HTML. There are two main types of components: Class components and Function components and now I will explain the difference:

A functional component is essentially a straightforward Javascript function. It accepts data in the form of props and, in return, yields a React element. Conversely, a class component involves the use of the class keyword,. It extends React.Component, thereby transforming the class into a fully-fledged React component.

Conclusion

So, think of React components like those handy building blocks you use. They're bits of code that you can use over and over again, making your websites dynamic and interactive. Whether you're into functional components (kind of like straightforward JavaScript functions) or class-based ones (a bit fancier with the class keyword and all), these components do specific jobs, take in data through props, and give you back those neat React elements.

Day 1 of adventofcode is complete. You have learnt something 🎄

KEEP CODING!!

Top comments (0)