useObjectRef may have an issue
              
              #3508
            
            
              
                Unanswered
              
          
                  
                    
                      alirezamirian
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment
-
| if you find an issue, please feel free to open a PR to address it or even just add a test. we haven't found any problems with it as of yet, but that doesn't mean we can't improve it. | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
useObjectRefsyncs the forwarded ref with the returned object ref, in a layoutEffect, which has the forwarded ref as a dependency:react-spectrum/packages/@react-aria/utils/src/useObjectRef.ts
Line 43 in 24afd2a
Since the ref object doesn't change across renders, it probably means the ref is synchronized only after the first render. I haven't come up with a concrete problematic case, but it seems the layoutEffect, shouldn't have any dependency, letting the ref value be synchronized after each render.
I hesitated to create an issue, since I haven't checked the issue in an example yet.
Beta Was this translation helpful? Give feedback.
All reactions