What's a Pure Function...
What's a Pure Function...
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
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào