TL; DR Flatlist, SectionList, VirtualizedList
это React.PureComponent
остальные компоненты React.Component
.
Как узнать, какой компонент использует PureComponent
Вы можете проверить исходный код компонентов React-native на Github, которые используют PureComponent или обычный компонент.
Вы видите, что TouchableOpacity из React-Native расширен с помощью Component.
Источник TouchableOpacity
But on the other hand, you can see FlatList uses PureComponent
Источник FlatList
Also, you can see SectionList
is used to React.PureComponent
Источник SectionList
Here is the Text component of React-Native
which is not using React.PureComponent
.
Источник текста
So the conclusion is by default every component extends with React. Component
excluding those components which they have mentioned in the docs that they are using React.PureComponent
.
Where to use useCallback hook
So as you know, the Pure component is used to optimizing rendering of a class component
so if you wanted to optimize functional component, then?
you can use React.memo
useCallback is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders (e.g. shouldComponentUpdate).
Learn about when to use memo or useCallback
read this interesting article.
https://kentcdodds.com/blog/usememo-and-usecallback