Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useCommittedRef.js 550B

1234567891011121314151617181920
  1. import { useEffect, useRef } from 'react';
  2. /**
  3. * Creates a `Ref` whose value is updated in an effect, ensuring the most recent
  4. * value is the one rendered with. Generally only required for Concurrent mode usage
  5. * where previous work in `render()` may be discarded befor being used.
  6. *
  7. * This is safe to access in an event handler.
  8. *
  9. * @param value The `Ref` value
  10. */
  11. function useCommittedRef(value) {
  12. var ref = useRef(value);
  13. useEffect(function () {
  14. ref.current = value;
  15. }, [value]);
  16. return ref;
  17. }
  18. export default useCommittedRef;