Passing Props From Child to Parent Component in React.js

Опубликовано: 30 Сентябрь 2024
на канале: TomDoesTech
77,080
1.1k

Is it possible to pass props from a child component to a parent component in React.js? Technically, no. By watching this video you will learn two methods that will help you solve the problems that you were hoping to solve by passing props from children to parents components.

The first method is to simply pass a function to the child component that allows you to set a value in the parent component.

The second method is to return an object from the child component, allowing you to pass down its properties and render function to the parent component. Remember, React.js components are simply functions and with the factory function design pattern, you can return objects from your components. The returned object can contain a render method and the second is the props that you want to pass from the child to the parents component.

🌎 Follow me here:
Discord:   / discord  
Twitter:   / tomdoes_tech  
Facebook:   / tomdoestech​  
Instagram:   / tomdoestech​  
TikTok:   / tomdoes_tech  
☕ Buy me a coffee: https://www.buymeacoffee.com/tomn