Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Try wrapping the function in React.memo()
Maybe it will get rid of unnecessary redraws if they occur with the same props
UPD:
1 option using hooks:
const App = (...) => {
...
const memorizedMessagesChecked = useMemo(() => <MessagesChechked {...props} />, [props.match.params.id])
return (
<SomeComponents />
{memorizedMessagesChecked}
)
}
class MessagesChechked extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
if (nextProps.match.params.id === this.props.match.params.id) {
return false
}
return true
}
...
}
const MessagesChechked = (...) => {
...
}
const isEqual = (prevProps, nextProps) => {
return prevProps.match.params.id !== nextProps.match.params.id
}
export default React.memo(MessagesChechked, isEqual)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question