亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我是react的新手.js我正在使用state鉤子,我得到了這個錯誤任何解決方案請

我是react的新手.js我正在使用state鉤子,我得到了這個錯誤任何解決方案請

RISEBY 2022-08-04 10:14:26
React Hook “useState”在函數“app”中調用,它既不是 React 函數組件,也不是自定義 React Hook 函數 react-hooks/rules-of-hooks    import React, {useState} from 'react';    import logo from './logo.svg'    import Person from './Person/Person';    import './App.css';    const app = props =>{      const [Personstat, setPersonstate]= useState({        persons : [          {name:"Amir", age:"25"},          {name:"Amir Yousaf", age:"22225"},          {name:"Amir Yousaf Maher", age:"25"}        ]      });     const switchNameHandler = () =>{        //alert('hello Listener');        setPersonstate( {    persons : [            {name:"Qasin", age:"23"},            {name:"Qasin Yousaf", age:"22"},            {name:"Qasin Yousaf Maher", age:"215"}          ]        })};      return (        <div className="App">          <h1>Hello  I am trying to learn js </h1>          <Person name={Personstat.persons[0].name} age={Personstat.persons[0].age}/>          <Person name={Personstat.persons[1].name} age={Personstat.persons[1].age}>I am try my best for learning</Person>          <Person name={Personstat.persons[2].name} age={Personstat.persons[1].age}/>          <button onClick={switchNameHandler}>Switch Name</button>        </div>      );    }    export default app;
查看完整描述

1 回答

?
蕪湖不蕪

TA貢獻1796條經驗 獲得超7個贊

React 組件名稱必須以大寫字母開頭。將組件名稱更改為“應用”。


查看完整回答
反對 回復 2022-08-04
  • 1 回答
  • 0 關注
  • 74 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號