skip to Main Content

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


  1. You should check useRef

    useRef is a React Hook that lets you reference a value that’s not needed for rendering.

    https://react.dev/reference/react/useRef

    Login or Signup to reply.
  2. You can use React.memo with a custom comparison function. https://react.dev/reference/react/memo

    Login or Signup to reply.
  3. You 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search