Is it safe to remove useState for just initialization? #59
              
                Unanswered
              
          
                  
                    
                      rostero1
                    
                  
                
                  asked this question in
                General Questions
              
            Replies: 2 comments
-
| Or is this cache like the cache for useMemo where it can be wiped out at any time during the lifetime of the component. | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| Still curious about the cache, but did find this work that indicates we should not do this: https://github.com/facebook/react/pull/31960/files | 
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.
-
Is it safe to replace
const [displayId] = React.useState(() => randomId2());with justconst displayId = randomId2();since there is no compiler lint warning and the compiler seems to handle this correctly. If not, can this be clarified in a doc somewhere if it does not already exist?Seems stable with
Beta Was this translation helpful? Give feedback.
All reactions