Skip to content
Home » META » Meta Front-End Developer Professional Certificate » Advanced React » Week 4: Final project

Week 4: Final project

In this module, you will be assessed on the key skills covered in the course and create a project to add to your portfolio.

Learning Objectives

  • Synthesize the skills from this course to create a portfolio.
  • Reflect on this course’s content and on the learning path that lies ahead.

Graded assessment


Video: Course recap: Advanced React

Advanced React: Key Topics Recap

This summary highlights the main concepts covered in the “Advanced React” course:

Components:

  • Setting up projects in VS Code.
  • Rendering lists and using keys.

Forms:

  • Understanding controlled vs uncontrolled components.
  • Building a registration form.

React Context:

  • Connecting props, state, and context.
  • Creating a light/dark theme switcher.

Hooks:

  • Using useState for complex data and managing state.
  • Leveraging useEffect for side effects.
  • Implementing custom hooks like usePrevious.

JSX:

  • Deep dive into JSX components and elements.
  • Mastering component composition with children.
  • Building a radio group component.

Reusing Behavior:

  • Managing cross-cutting concerns with higher-order components (HOCs).
  • Utilizing render props for code sharing.

Testing:

  • Writing integration tests with Jest and React testing library.

Remember, this recap is just a starting point. Test your knowledge in the graded assessment and keep learning!

In this course you learned
about advanced React. Let’s take a few moments to recap the key topics
that you learned about. In the opening module, you received an
overview of components. During the first lesson, you received an
introduction to the course. You discovered how to set
up a project in VS Code, and you learned how to make
the most of the content in this course to ensure that
you succeed in your goals. You then moved on
to the next lesson, in which you learned how
to render lists and React. In this lesson,
you learned how to transform and rendered
list components, create a basic list
component and you learned about keys within
list components and React. In the next lesson, you
explored forums and React. First, you learned about
the differences between controlled and
uncontrolled components. Next, you discovered
how to create a controlled form
component in React, and then had a chance
to test your skills by creating your own
registration form. In the last lesson, you learned about React Context. You’ve explored props and state and how they
relate to context. You also learned how re-rendering
works with context and you apply their
knowledge to create a light, dark theme switcher. Next, you began
the second module, which covered all
the common hooks and React and how to
build custom hooks. In the first lesson
of this module, you got started with hooks. You learned how to implement the useState hook to work with complex data and apply this knowledge to manage
state within a component. You also learned about side effects and
they useEffect hook. In the next lesson, you move down to the rules of hooks and fetching
data with hooks. You discovered the
essential rules of hooks and how to use them
effectively in your solutions. You also gained an
in-depth explanation on how to fetch data using hooks and tested your skills in fetching data in a
practical exercise. In the final lesson
of the module, you enhanced your knowledge and skills with advanced hooks. You learned about the
benefits of the use reducer hook and
how it differs from useState and how to access the underlying DOM with useRef. You then build your own
custom hook use previous. In the third module, you’ve explored JSX
in more detail, and how to test your solutions. In the first lesson, you took a deep dive into JSX. You gained a more
detailed overview of JSX components and elements. Next, you explored
component composition with children with
its two key features, containment and
specialization, and how to dynamically manipulate
children in JSX. You had the opportunity to apply your new skills and building
a radio group component, and we’re introduced to
spread attributes in JSX. In the next lesson, you focused on reusing behavior. You learned about
cross-cutting concerns and React and explored higher-order components and how they’re used to great effect. You also learned about a
specific HOC called Render props and used random
prompts to implement scroller position
tracking in a solution. In the final lesson
of this module, you were introduced to integration tests with
React testing library. You’ve discovered jest and
the React testing library. You wrote test scenarios
for a form and we’re introduced to
continuous integration. You’ve reached the end
of this course recap. It’s now time to
try out what you’ve learned in the graded
assessment. Good luck.

Reading: About the final project

Reading

Reading: Popular external libraries

Reading

Lab: Create your portfolio

Header.js

u003cstrongu003eLandingSection.jsu003c/strongu003e

u003cstrongu003eProjectsSection.jsu003c/strongu003e

u003cvaru003eContactMeSection.jsu003c/varu003e 

Video: Solution walk-through: Portfolio

Portfolio Website Breakdown: Built with Chakra UI and Formik

This is a well-structured breakdown of a portfolio website built with React, Chakra UI, and Formik. Here are the key points:

Overall Structure:

  • Uses Chakra UI for pre-built UI components (boxes, stacks) and styling props.
  • Employs React Context for a global “Alert” component.
  • Follows a clear layout: Header, Landing, Projects, Contact, Footer.

Key Components:

  • Header: Renders social media links using map function and smooth animation with hooks.
  • Landing Section: Simple layout with image and text.
  • Full Screen Section: Reusable component for full-screen sections with customizable background and text color.
  • Projects Section: Presents featured projects in a visually appealing layout.
  • Contact Me Section: Star of the show!
    • Uses Formik for form handling and validation.
    • Includes text inputs, a select box, and a text area.
    • Validates inputs using Yup library.
    • Submits form data to a simulated API endpoint.
    • Shows success/error messages using alerts.

Overall Impression:

  • Well-organized and explained code.
  • Effective use of libraries like Chakra UI and Formik.
  • Focus on both visual appeal and functionality.

Possible Discussion Points:

  • Could explore alternative libraries or approaches for specific components.
  • Discuss potential improvements to the API call simulation.
  • Consider adding more sections or features to the portfolio.

Tutorial: Building a Portfolio Website with Chakra UI and Formik

Ready to showcase your skills with a stunning online portfolio? This tutorial guides you through creating a React portfolio website using the powerful combination of Chakra UI and Formik.

Prerequisites:

  • Basic understanding of React
  • Familiarity with JavaScript fundamentals

Step 1: Setting Up the Project

  1. Create a new React project using your preferred method (e.g., Create React App).
  2. Install the required dependencies:

Bash

npm install @chakra-ui/react @emotion/react @emotion/styled yup formik

Step 2: Building the Layout with Chakra UI

  1. Design your portfolio’s layout using Chakra UI components. Explore the library’s documentation for various options like Box, HStack, VStack, and more.
  2. Create separate components for Header, Landing, Projects, Contact, and Footer sections.
  3. Style each component using Chakra UI’s built-in props and themes.

Step 3: Adding Smooth Animations (Optional)

  1. Utilize React hooks like useRef and useEffect to achieve smooth animations for elements like the header.
  2. Explore third-party animation libraries like Framer Motion for more complex animations.

Step 4: Creating the Landing Section

  1. Build a simple layout for the Landing section using Chakra UI components.
  2. Include your profile picture, a brief introduction, and any relevant call to actions.

Step 5: Showcasing Projects with a Reusable Component

  1. Develop a Full Screen Section component that adapts to different backgrounds and text colors.
  2. Use the children prop to allow customization of content within the section.
  3. Dynamically render your project information using data structures like arrays or objects.

Step 6: Building a Contact Form with Formik

  1. Integrate the Formik library for efficient form handling and validation.
  2. Define form fields (name, email, message) using Formik’s useFormik hook.
  3. Set up validation rules using Yup for ensuring data integrity.
  4. Implement error handling and display clear messages to the user.

Step 7: Submitting Form Data and Handling Responses

  1. Connect the form submission to a simulated API call (using tools like axios or fetch).
  2. Show success or error messages based on the API response using Chakra UI’s Alert component.
  3. Optionally, reset the form upon successful submission.

Step 8: Adding Polish and Personalization

  1. Customize the overall look and feel using Chakra UI’s theming capabilities.
  2. Integrate social media links and other relevant information.
  3. Deploy your portfolio to a hosting platform like Netlify or Vercel.

Bonus Tips:

  • Explore advanced Chakra UI features like custom components and theming.
  • Add interactivity to your portfolio using React Router for navigation.
  • Consider accessibility best practices for an inclusive user experience.

Remember, this is a foundational guide. Feel free to experiment, add your creative flair, and make this portfolio website truly your own!

Let’s now work through what I’ve produced
and please, if you find something that inspires, don’t hesitate to incorporate it
into your own solution as well, all right, let’s get started. I’m using a UI Library, Chakra UI,
that offers a pre set of styles for your React components. That allows me to avoid worrying too much
about CSS and focus on the business logic for my portfolio page, let’s have a click
overview of the whole application. The layout consists of a header that
contains links to all my relevant social media accounts, and links to
the different sections of the page. There are three full screen sections,
a landing section with a profile picture, and a quick description about myself. A project section with a list of all past
projects I’ve worked on, and finally, a Contact me section, to allow visitors to
contact me by filling out a simple form. Finally, there’s a footer at the bottom, this application level layout is defined
at the entry point, the app.js component. Besides the two providers at the top,
everything inside the main tag translates the different UI boxes that I described
previously, Header, Landing section, Project section, Contact me section,
Footer, and Alert. The Alert component plays the role of
a global dialogue that I can trigger from anywhere in the application,
using React context. Let’s go into each section, top to bottom,
starting with the header components. It’s rendering section begins to
illustrate one of the compelling points from the Chakra UI Library. First, Chakra provides you with
generic boxes, like box Hstack for horizontal stacks or rows, and
Vstacks for vertical stacks or columns. That use the special children prop
to place their content as you wish, using properties such as padding,
margin, or spacing. Secondly, Chakra uses props for
all CSS styles, as well as additional ones like spacing,
to evenly separate a group of children, siblings, or in other words,
at similar gaps between them. I’m rendering a list of social
icons using the map function, picking as key their URL,
which is unique per item. Now, if you examine this rendering, you will find two of the core React
hooks use ref and use effect. Those two are used in conjunction
to achieve this smooth animation of the header, you can find out more about
the implementation details in a further reading. Okay, let’s now check the next component,
Landing section, there’s nothing particularly
special about this component. Is just a presentational component that
encompasses the whole screen height, and lays an image and text in the center. Still, there’s a great component I created
that uses some of the techniques you have learned, the Full Screen
section component. Here is a component that leverages both
the children prop and the spread operator. Its goal is pretty simple, to create a
full screen container box with 1280 pixels as width, with a specific
background color and text color, depending on whether
the background is dark or light. The spread operator allows you
to pass down other layout props, the vertical stack components, in case
you would need further customization. Next, there’s Project section, this is
another presentational component that renders all my featured
projects in a great layout. And finally I will move on
to the star of the show, the Contact me section component. This is probably the most interesting
component of them all since it implements a controlled form of validation and
handles some aspects of internal state. To simplify the form business logic,
I have decided to use another library that is well known
within the React community, Formik. Formik is the most popular open
source form library for React, and it stands out due to its declarative
nature, allowing you to spend less time wiring up state and change handlers, and
more time focusing on your business logic. Looking at the application, I have
added four inputs, one text input for the first name,
another text input for the email, a select input to pick the type of
inquiry, and finally, a common text area. To define the configuration of the form,
you would have to use the useFormik hook, this hook takes a configuration object
that is intuitive and easy to follow. Initial values defines the initial state
of the form, Onsubmit is a function that will be executed once users
click on the Submit button, and validation schema specifies the validation
rules for this form on the client side. Formik works very nicely in conjunction
with the Yup, a library that lets you define your validation in a declarative
way, using a chain of operators. The hook returns the Formik object, that
is what you have to use to wire up your inputs with the Formik internal state. Now let’s explore the business of
rendering, I have grouped each input into a FormControl component,
which is imported from Chakra. For example, the first name has a label,
the input itself, and a component to display any error messages
occurring for that particular input. There is invalid prop, and the form control determines whether
the error message is shown or not. For the first name, It would happen if there’s an error
according to its validation rules and it has been touched, meaning the user has
already focused the input at least once. And the input component I would have
to hook the state and change handlers, by using formik.getfieldProps, with
the value of first name as the parameter. Which would have to match the property
name used in initial values, and spreading the results, which is an object with all
the props you need to connect from Formik. So if I go to the form, focus
the first name input and then blur it, an error message pops up on the bottom
with a hint required, nice isn’t it? The remaining inputs follow
a similar pattern, so I won’t focus too much on them. Finally, we have the form submission, remember the OnSubmit property from
the useForm make hook configuration? That’s the function that will be
called when the form is submitted, in that function, an API call is performed
to the endpoint to submit the form along with the form values. Finally, they useEffect hook listens
to changes in the response value, and once the server responds, it will open an alert showing a dialog
with a confirmation or an air message. This API call is just a simulation for
the purpose of the exercise, and it’s programmed in a way that
has 50% chance of being successful. If the response is successful,
the form is reset and cleared using the recent form
function from the Formik object. Well, let’s explore the form in action,
I will fill the form with values, click Submit, and voila, here is the alert, we
can try again to show the opposite state. So there you have it, this is one possible
solution to the portfolio exercise, I’m really looking forward to seeing
which approach you took to complete this challenge.

Reading: Solution code

Reading

Quiz: Final graded quiz: Advanced React

You are building a form using both Formik and Yup libraries, where one of the inputs is an email. u003cbru003eHere are this input’s client validation rules:u003cbru003eIt has to be a valid email address.u003cbru003eIf the email input is invalid, a message “Invalid email address” will be displayed.u003cbru003eIf the email input is blank, a message “Required” will be shown.u003cbru003eBased on the above requirements, choose the correct Yup validation code from the provided options.

You have the following React application where you have a ToDo component that has 2 text labels and an uncontrolled text input and the entry point App component that renders a list of two ToDos and a button to reverse the order of the ToDos. To avoid a React keys warning, a key is provided to each ToDo component, with the index as its value. Suppose that the next sequence of events happen in the application:u003cbru003e1. You write “Do laundry” in the first ToDo inputu003cbru003e2. You write “Go shopping” in the second ToDo inputu003cbru003e3. You click the button to reverse the orderu003cbru003eWhat would happen on the screen after that?

Consider the code below, and choose the correct sentence about this code.

Select all the statements that are true for React elements:

True or false: When the user clicks the Submit button, the “WithClick” string will never be output to the console.

True or False: Using jest and react-testing-library, to assert that a function has been called with some specific arguments, you would need to use the u003cvaru003etoHaveBeenCalledWithu003c/varu003e matcher.

Is the following piece of code a valid implementation of the render props pattern?

What do you need to add to this code to make the u003cvaru003euseEffectu003c/varu003e run only once?

You are given the below piece of code.

Is the following code snippet valid? Why?

True or False: The type of a React element can be a DOM node, such as, for example, an HTML button.

When writing a test for a React component using jest and react-testing-library, how would you assert that a function has been called with some specific arguments?

Course wrap-up


Video: Congratulations, you have completed Advanced React!

Summary of the Advanced React Course Completion Message:

Congratulations! You’ve successfully completed the Advanced React course.

Key Learnings:

  • Advanced React features (unspecified details mentioned)
  • Testing React applications (using Jest and React Testing Library)
  • Advanced JSX usage (unspecified details mentioned)
  • Rendering list and form components effectively
  • Sharing global values using context API
  • Using all common React hooks and building custom hooks
  • Understanding JSX in depth
  • Encapsulating behavior with higher-order components
  • Writing tests for applications
  • Building a portfolio using React

Next Steps:

  • Consider enrolling in the next course to further develop your front-end development skills.
  • Apply your learnings in the final lab to build a full website using React.
  • Showcase your skills and knowledge to potential employers through your built website.
  • Earn a certificate in front-end development upon course completion.

Overall, the message encourages you to:

  • Celebrate your accomplishment: Acknowledge your hard work and skill development.
  • Recognize ongoing learning: Understand that learning is continuous.
  • Apply your knowledge: Utilize your acquired skills in practical applications.
  • Prepare for the future: Plan your career path and showcase your abilities.

Further Insights:

  • Specific details about the advanced React features learned are not provided.
  • The message emphasizes the practical application of skills (lab project, portfolio website).
  • Building a portfolio is highlighted as a means of demonstrating skills to potential employers.

You’ve reached the end of
this advanced React course. You’ve worked hard
to get here and developed a lot of new
skills along the way. You’re making great progress on your front end
developer journey, and you should now
understand how to use more advanced
React features, test your React applications and use JSX more proficiently. You were able to demonstrate
some of this learning along with your practical react
skill set in the lab project. Following your completion of this course and advanced React, you should now be able to render list and form components
efficiently in React. Demonstrate how context provides a way to share global values between components with a defined API and
potential applications. Use all common hooks in React, and put them to use within your application and build
your own custom hooks. The key skills measured in the
graded assessment revealed your ability to
understand JSX in-depth. Use advanced patterns
to encapsulate common behavior via
higher-order components , and render prompts. Write tests for
your application, and build a portfolio
using React. What are the next steps? This advanced React
course has enhanced your knowledge and skills
in several key areas. You probably realize that there’s still more
for you to learn. If you found this course helpful and want to discover more, then why not register
for the next course? You’ll continue to
develop your skill set during each of the front
end development courses. In the final lab, you’ll apply everything
you’ve learned to build your own fully functional
website using React. Whether you’re just starting out as a technical professional, a student, or a business user, the course and projects
prove your knowledge of the value and capabilities
of front end development. The lab consolidate
your abilities with a practical
application of your skills. But the lab also has
an important benefit. It means that you’ll have a
fully operational website built using React that you can reference within your portfolio. This serves to demonstrate your skills to
potential employers, and not only does it show employers that you are
self-driven and innovative, but it also speaks volumes
about you as an individual. As well as your newly
obtained knowledge. Once you’ve completed
all the courses, you’ll receive a certificate
in front-end development. These certificates provide
globally recognized and industry endorsed evidence
of your technical skills. Thank you. It’s
been a pleasure to embark on this journey
of discovery with you. Best of luck in the future.