r/learnreactjs • u/its-procodester • Aug 15 '24
Question Wrap SVG in React.memo?
Is it beneficial to wrap an SVG component in React.memo to prevent unnecessary re-renders, considering they are pure components?
2
Upvotes
View all comments
Show parent comment
1
u/detached_obsession Aug 24 '24
Even if a parent component re-renders too often to the point of causing issues, then the cause isn't the SVG component, it's something else that should be optimized. If in fact the SVG is large and complex and there are noticeable performance issues then I agree with using React.memo or other memoization techniques on that component.
My point still stands that it should depend and it shouldn't be done without first doing some kind of performance measurements.