Error code
import {useState,useEffect} from 'react'
const useData = () => {
const [data,setData] = useState({count:0});
useEffect(()=>{
setTimeout(()=> {
setData((data)=>({...data,count:data.count+1}))
}, 1000 );
},[])
return {data}
}
export default useData
Modified code
import React from 'react'
import useData from '../hooks/AppData'
const AppData = ()=>{
const {data} = useData()
return <div>
count->{data.count}
</div>
}
export default AppData; // Change the first letter of the name to uppercase
Read More:
- Taro Use React Hooks Error: TypeError: Object(…) is not a function
- [Solved] react Error: Can‘t perform a React state update on an unmounted component
- [Solved] swiper Error: The requested module ‘react’ is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export
- [Solved] Vue Error: Failed to mount component: template or render function not defined
- Attempted import error: ‘mobx-react‘ does not contain a default export (imported as ‘observer‘).
- [Solved] react18 swiper Error: Cannot read properties of undefined (reading ‘wrapperClass’)
- Solve the data transfer between vue irrelevant components error: this.$store.commit is not a function
- NPM install -g create-react-app [How to Solve]
- TypeError: res.render is not a function
- this.$el.querySelectorAll is not a function [How to Solve]
- NPM install Error cb.apply is not a function
- mmdetection Error when running voc.py: KeyError: ‘NumClassCheckHook is already registered in hook‘
- TypeError: db.collection is not a function
- [Solved] Vue Install less Error: this.getOptions is not a function
- QT solves error: use of deleted function and is private within this context
- React ant design pro Error reported in the background after removing internationalization
- Syntax Error: TypeError: this.getOptions is not a function
- [Solved] Tensorflow2.0 Error: Function call stack:distributed_function
- error: field ‘XXX’ declared as a function [How to Solve]
- [vite] Internal server error:options.devServer.transformWidthEsBuild is not a function…