Câu hỏi phỏng vấn Reactjs
Câu hỏi

What are two types of components in ReactJS?

Câu trả lời

In ReactJS, there are two primary types of components:

  1. Functional Components: These are JavaScript functions that return JSX, which is used to render UI components. Functional components can receive data as props, but they do not manage or contain their own state. They are also known as stateless components because of this characteristic. An example of a functional component is as follows:
jsx Copy
function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}
  1. Class Components: These are more complex and are defined by ES6 classes that extend from React.Component. Class components can manage their own state and contain lifecycle methods, making them stateful. They also have a render method that returns JSX. An example of a class component is:
    ...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What are the differences between a Class component and Functional component?

junior

What are the advantages of using React?

junior

What is the purpose of callback function as an argument of setState ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào