ReactJS - render called, but DOM not updated

后端 未结 4 2377
终归单人心
终归单人心 2021-02-19 05:55

This has happened to me a few times. I have always managed to work around the issue, yet I am still intrigued to understand why this happens, and what I have missed.

Ess

4条回答
  •  鱼传尺愫
    2021-02-19 06:50

    Try something Like this:

    this.setState((state) => ({
       ...state, renderCondition: true
    }));
    

    Maybe you're doing another setState for renderCondition some where the code above should fix such things.

    or maybe try using PureComponent

    import React, { PureComponent } from 'react'
    
    export default class TablePreferencesModal extends PureComponent {
      render() {
        return (
          
    ) } }

提交回复
热议问题