Hey today we will see the functional component.
Functional Component
import React from "react";
//below we have imported a component ShowQuestion.
import ShowQuestion from "./ShowQuestion";
const items = [
{
title: "what is react",
content: "react is js library",
},
{
title: "what is virtual dom",
content: "it is clone of real dom",
},
];
const App = () => {
/*the app component that is a functional component returning another
component ShowQuestion*/
return (
<div>
/*you can see we have passed our collection items with ShowQuestion
component. THis is how we pass props. items is props name with
value {items}. Now this props will be used by the ShowQuestion
component.
*/
<ShowQuestion items={items} />
</div>
);
};
export default App;
No comments:
Post a Comment