Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100868282
useCommittedRef.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 3, 10:58
Size
551 B
Mime Type
text/x-java
Expires
Wed, Feb 5, 10:58 (2 d)
Engine
blob
Format
Raw Data
Handle
24045815
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
useCommittedRef.js
View Options
import { useEffect, useRef } from 'react';
/**
* Creates a `Ref` whose value is updated in an effect, ensuring the most recent
* value is the one rendered with. Generally only required for Concurrent mode usage
* where previous work in `render()` may be discarded before being used.
*
* This is safe to access in an event handler.
*
* @param value The `Ref` value
*/
function useCommittedRef(value) {
var ref = useRef(value);
useEffect(function () {
ref.current = value;
}, [value]);
return ref;
}
export default useCommittedRef;
Event Timeline
Log In to Comment