handling props in functional components reactjs ijnterview questions 1

handling props in functional components reactjs ijnterview questions

function StudentInfo(props){
 return(
   

{props.name}

{props.rollNumber}

) }

Here is what the above code is Doing:
1. We are creating a function called StudentInfo.
2. We are passing props as a parameter to the function.
3. We are returning a div with two h2 and h4 tags.
4. We are using the props parameter to access the name and rollNumber properties.
5. We are using the name and rollNumber properties to display the name and rollNumber of the student.

Now, let’s use the StudentInfo component in the App component.

Similar Posts