第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

React 狀態(tài)值在傳遞給模型時(shí)變?yōu)?null

React 狀態(tài)值在傳遞給模型時(shí)變?yōu)?null

慕勒3428872 2022-05-14 14:40:04
我有 AboutMeText 狀態(tài)并且它通過道具成功更新,我成功顯示了它的值<h6>{this.state.AboutMeText}</h6>,但是當(dāng)我嘗試將此狀態(tài)值傳遞給模型時(shí),它的值變?yōu)榭?。我已?jīng)嘗試過 {this.state.AboutMeText}或{this.props.AboutMeText}沒有工作請幫助我先生,我是 React js 的新手 <DIV className="template-profile">   <Image     url={this.state.selectedImages.profilePicture}     mode={"Profile"}   />   <h6>Hello I'm</h6>   <h1 className="template-profile-name">     Nabnit Jha   </h1>   <h6>     {this.state.AboutMeText} // here state value display successfully   </h6>   <DIV className="template-self-info">     <Modals modalBody={this.state.AboutMeText} modalHeading="About Me"></Modals> // here state value became null   </DIV> </DIV>
查看完整描述

2 回答

?
元芳怎么了

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果我正確理解您的問題。您需要設(shè)置默認(rèn)狀態(tài)以避免空數(shù)據(jù)


如果在類的構(gòu)造函數(shù)中使用類組件,則應(yīng)設(shè)置狀態(tài)的默認(rèn)值


class SomeComponent extends React.Component {

   constructor(props) {

    super(props);

    this.state = {

         someData: []

    };

   }

}

如果你使用功能組件,你應(yīng)該使用反應(yīng)鉤子


const SomeComponent = () => {

   const [items, setItems] = useState([]); // default value empty array

};


查看完整回答
反對 回復(fù) 2022-05-14
?
一只萌萌小番薯

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊

根據(jù)以下條件打開您的模型 -


               <DIV className="template-profile">

                    <Image

                        url={this.state.selectedImages.profilePicture}

                        mode={"Profile"}

                    />

                    <h6>Hello I'm</h6>

                    <h1 className="template-profile-name">

                        Nabnit Jha

                    </h1>

                    <h6>

                    {this.state.AboutMeText} // here state value display successfully

                    </h6>

                    <DIV className="template-self-info">

                        {modelStatus&&<Modals modalBody={this.state.AboutMeText} modalHeading="About Me"></Modals>}

                        //here state value became null

                    </DIV>

                </DIV>

實(shí)現(xiàn)它的功能


功能clickHandle


clickHandle=()=>{

  this.setState({modelStatus:true})

}

您根據(jù)您的要求使用您的功能。


查看完整回答
反對 回復(fù) 2022-05-14
  • 2 回答
  • 0 關(guān)注
  • 219 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號