React tutorial for beginners #20 Pass Function as Props

preview_player
Показать описание
In this react js tutorial for beginners series we learn how to pass function as a props in child component in react js. This video is made by anil Sidhu in the English Language.

Make child component
Make a function for pass as props
pass function as props
call function from child component
why this is important
Interview Question
Рекомендации по теме
Комментарии
Автор

I simply love you. I love your accent. I love the smell of curry. I love Indian music. I love everything about India.

gorkemgok
Автор

Thanks for the clear and concise explanation!

shannonthouvenin
Автор

very well explained, one of the best tutorial!

SuperSyedzeeshan
Автор

Hi i have question: it means that I need all that time put component in position like parent in app.js if i would use function in one component and use this functionality in other component

danielsladecek
Автор

Thank you for the tutorial, it help me resolved a login form that I was trying to build.

ysaiaspaul
Автор

Parent:
function App(){
const [data, setData] = useState('initial');
return(
<h1>{data}</h1>
<User
);
}


Child:
function User(props){
<button
}

rafeedsultaan
Автор

My case: i need update sign that book is not available 'cause she is already borrowed, so i need use props between components, because i need make onClick () in one components and use this functionality in other components, so do i need still put component to parent position ?

danielsladecek
Автор

Thanks for the solution. You're a life saver.

chassismagic
Автор

This function is written in "App.js" and your calling it in "User.js".
What if we have written a function in "User.js" and we have to call it in "App.js". How can we do that?
please let me know.

samriddhabajpai
Автор

Can you please explain how to write unit test for that component which has function as a prop

rajakulainukala
Автор

what if it had parameters to pass? I'm trying the intuitive way "{this.props.data(this.props.prop1, this.props.prop2)}" and it's not working

henriquetaa