Mstar0816 / Portfolio

https://my-portfolio-ten-orpin-68.vercel.app
4 stars 0 forks source link

Unmanageable Prop Drilling #4

Open Mstar0816 opened 7 months ago

Mstar0816 commented 7 months ago

In deeply nested component trees, passing props down to multiple levels can become unwieldy and hard to maintain.

Mstar0816 commented 7 months ago

Context API: Use React’s Context API to share data between components without manually passing props through each level. // Creating a context const MyContext = React.createContext();

// Providing context value in a parent component <MyContext.Provider value={/ value /}> {/ Nested components /} </MyContext.Provider>

// Consuming context value in a child component

{value => /* Use value */}