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:
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

middle

What's the difference between an Element and a Component in React?

junior

When rendering a list what is a key and what is it's purpose?

middle

How would you pass data from child to parent component in React?

Bình luận

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

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