[英]how to stop re-render in reactjs?
case 'splitWord': if(this.props.remedStatus){ console.log(this.props.remedStatus) console.log("remed") return( <HotspotRemed xml={this.receivedXML} userXml={this.usersAnswerXML} correctAnswer ={this.ansString} type={this.splitType} /> ) } else { console.log("reurn word") return( <div style ={wrap_style} > {this.forceUpdate} <SplitXMLPreview xml={this.receivedXML} type='w' assignedSplitContentClick={(contentId, selectionType) => { this.handleSplitContentClick(contentId, selectionType, 'w') }} getCorrectAns={(answers) => { this.correctAnswers = answers }} /> </div> ) } break <<<==NOW HERE IS MY RENDER MEHTOD.==>>> render() { console.log("render") return ( <div className="previewtemplate" style ={template}> {this.templateArea(this.state.templateType)} </div> ); } }
我只是想知道如何停止重新渲染組件。
當我單擊一個按鈕時,我有三個按鈕,它在那里執行操作。
有一個按鈕。 在我使用if的情況下,當我單擊該按鈕時,它返回false和component false調用,這很好用,當再次單擊該按鈕時,它調用true組件,這對我來說也很好,但是當我再次單擊按鈕時首先調用渲染,然后調用我的組件。 我不想將其稱為渲染。
我讀了一些博客,他們建議使用this.forceupdate。 我該怎么辦?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.