Zettelkasten
week01
Context in React

#topic


What you know about Props and State


Props and state are two fundamental concepts in React. Props are used to pass data from a parent component to a child component, while state is used to manage data within a component.

Whats is Context and Why its used


The React Context API is a way to share data between components without having to pass props down through the component tree. It is useful for sharing global state, such as the current user or the current theme.

📑 StudyNotes/Programing/Courses/ReactMetaCourse/Modules/Week01/Context/Exercise/Exercise


You've learned about React Context and how it allows you to define global state without passing individual props down through each component. One of the most common use cases for Context is to define a theme for your application. In this exercise, you'll create a light-dark theme switcher.

My Solution (Context)

How re-rendering works with Context


In this reading you will learn about the default behavior of React rendering and when context is used. You will discover how to prevent unnecessary top-level re-renders with React.memo and how object references work in JavaScript. You will also learn how to utilize the useMemo hook to guarantee object references don’t change during re-rendering.