Home > Back-end >  _reactNative.useState is not a function
_reactNative.useState is not a function

Time:08-30

hi everyone i'm just learning hooks in react native and i get an error when i try to execute the function written below. The code is:

    aa(){
      const [booblenavalue,setboolenavalue]=useState(false)
              useEffect(() => {             
              setboolenavalue(true)
            }, [])            
  }

My code don't work.My error is:" TypeError: (0 , _reactNative.useState) is not a function". How can I fix this error?

CodePudding user response:

        import React,{useState} from 'react';

        const aa = () => {
             const [booblenavalue,setboolenavalue]=useState(false)
                                                                 
             useEffect(() => {
                 setboolenavalue(true)
             }, []);
        }

        export default aa;

Maybe this must be the format of your code

  • Related