0 votes
1 view
in Web Technology by (24.1k points)

Can anyone please explain the component with an example in React JS?

1 Answer

0 votes
by (46.9k points)
edited by

A component in React JS is just like the functions we use in JavaScript but return HTML by using render function

Components are of two types such as Class components and Function components

Example of Class Component in React JS: 

class Potato extends React.Component {

 render() {

    return <h2>Hi, I am a Potato!</h2>;

 }

}

Example of function component in React JS:

function Potato() {  

return <h2>Hi, I am also a Potato!</h2>;

}

In case you are interested to learn web development, you can take up this Web development course by Intellipaat

You can watch this video on React JS course for beginners to learn about components with example in React JS:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Mar 27 in Web Technology by Sudhir_1997 (24.1k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 27 in Web Technology by Sudhir_1997 (24.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...