Is it possible to change the props of a Component without a re-render. In react native I need to change the scrollEnabled
prop of scrollview without re-rendering the whole UI.
Would this be possible by going really deep down the Component API or something and changing that prop without a whole re-render?
3
Answers
You should check
useRef
https://react.dev/reference/react/useRef
You can use
React.memo
with a custom comparison function. https://react.dev/reference/react/memoYou can’t get the new value of state or prop without rerendering the component.
But you can prevent rerendering of those components, that don’t require those props.
You can use
React.memo
. It prevents renendering of the component, if its props don’t change. Be careful how you handle objects, arrays, functions… because they get new reference on each render.