Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react userefrence example

import { useRef } from 'react';

function MyComponent() {
  const reference = useRef(initialValue);
  const someHandler = () => {
    // Access reference value:
    const value = reference.current;
    // Update reference value:
    reference.current = newValue;  };

  // ...
}
Source by dmitripavlutin.com #
 
PREVIOUS NEXT
Tagged: #react #userefrence
ADD COMMENT
Topic
Name
3+3 =