[英]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.