React Hook “useState” is called in function “app” which is neither a React function component or a custom React Hook function

前端 未结 29 1058
花落未央
花落未央 2020-11-30 00:07

I\'m trying to use react hooks for a simple problem

const [personState,setPersonState] = useState({ DefinedObject });

with following depend

29条回答
  •  被撕碎了的回忆
    2020-11-30 00:42

    In the app function you have incorrectly spelled the word setpersonSate, missing the letter t, thus it should be setpersonState.

    Error:

    const app = props => { 
        const [personState, setPersonSate] = useState({....
    

    Solution:

    const app = props => { 
            const [personState, setPersonState] = useState({....
    

提交回复
热议问题