Learn

Well done! You’ve written your first function component. Here’s a recap:

  • Function components are React components defined as JavaScript functions
  • Function components must return JSX
  • Function components may accept a props parameter. Expect it to be a JavaScript object

Although function components and class components can do the same things, you’ll see a lot of function components in the React documentation and example apps. Some developers prefer them over class components for their simplicity and straightforward features, like Hooks, which you’ll learn later in your coding journey.

Instructions

Take a look at the example in the code editor. Make sure the code makes sense before moving on!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?