Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle

后端 未结 8 1724
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 10:12

I am receiving this warning message in my chrome console for my react-native project. Do you have any idea why I am getting this?

This is the complete message:

8条回答
  •  感动是毒
    2020-12-24 11:00

    I my case, I have sold the same problem in react-native navgiation.

    What I did ?

    Already I was using react-navigation like below

     export const containerRef = createRef();
    
     function App(){
       return (
         
           ....
         
       );
     }
    

    and then I was consuming it like:

    import {containerRef} from 'filename';
    
    onPress = ()=> containerRef.current.navigate('Chat');
    

    But I updated like below and warning has gone.

     function App(){
       return (
          // removed ref
           ....
         
       );
     }
    

    and then I was consuming it like:

    import { useNavigation } from '@react-navigation/native';
    
    onPress = ()=> useNavigation.navigate('Chat');
    

提交回复
热议问题