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

What's a Pure Function...

Câu trả lời

A Pure Functional Component in React refers to a functional component that behaves like a pure function in the context of React's rendering behavior. In functional programming, a pure function is one that always returns the same output given the same input and does not produce side effects. Similarly, in React, a Pure Functional Component is one that renders the same output given the same props and state, and does not produce side effects during the rendering process.

React provides a mechanism to optimize functional components through React.memo(). This higher-order component wraps a functional component and memoizes its output, preventing unnecessary re-renders when the component's props have not changed. This is analogous to the React.PureComponent class for class components, which implements a shallow comparison in the shouldComponentUpdate lifecycle method to determine if re-r...

senior

senior

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

senior

When would you use StrictMode component in React?

senior

How would you store non-state/instance variables in functional React components?

senior

What's the difference between useCallback and useMemo in practice?What's the difference between useCallback and useMemo in practice?

Bình luận

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

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