Share
Functional Components in React?
Question
- A functional component is just a plain JavaScript function which accepts props as an argument and returns a React element.
- It is like a normal function with no render method. It has no lifecycle, so it is not possible to use lifecycle methods such as componentDidMount and other hooks.
- When react renders our stateless component, all that it needs to do is just call the stateless component and pass down the props. you cannot use setState() in your component.
- The functional component is also known as a stateless component because it does not hold or manage state.
Example:
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
Leave an answer