What is component in reactjs
- 3. What is Component?
•Basic meaning of component is “one of several
parts of which something is made”
•In ReactJS one UI page is consists of so many
component(s).
•Components are independent and reusable
code. Building blocks of ReactJS Application.
- 4. What is Component?
•Components is like JavaScript functions, but work
individually to return JSX code as elements for UI.
•Parent Component is group of all child
components.
- 5. Types of Components
Functional Components
Class Components
Pure Component
High-Order Components
- 6. •Its like a function that takes in props and return JSX.
•JSX stands for JavaScript XML. It is simply a syntax
extension of JavaScript. JSX allows us to write HTML
in React.
•Functional component is also known as a stateless
component because not hold or manage state.
Functional Component
- 7. • Example: Hello.js
// Functional Component Example
import React from 'react';
function Hello(props){
return (
<h1>
Welcome to Learn {props.name}
</h1>
)
}
export default Hello;
Functional Component
- 8. • Example: HelloWorld.js
// Functional Component Example
import React from 'react';
const HelloWorld =()=> {
return (
<div>
<p>Hello World!</p>
</div>
)
}
export default HelloWorld;
Functional Component
- 10. // Class Component Example
import React from 'react';
class ViewHelloWorld extends React.Component {
render() {
return (
<div>
<p>Hello World!</p>
</div>
)
}
}
export default ViewHelloWorld;
Class Component