You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/24 06:56:03 UTC

[GitHub] [superset] stephenLYZ commented on a diff in pull request #19960: fix(dashboard): make to refresh all tab content charts

stephenLYZ commented on code in PR #19960:
URL: https://github.com/apache/superset/pull/19960#discussion_r880117491


##########
superset-frontend/src/dashboard/components/gridComponents/Chart.jsx:
##########
@@ -154,6 +157,10 @@ export default class Chart extends React.Component {
       return true;
     }
 
+    if (!isEqual(nextProps.chart, this.props.chart)) {

Review Comment:
   It makes sense to not render the chart when it is not visible, which improves performance. The same is true for fine-grained control of chart updates via SHOULD_UPDATE_ON_PROP_CHANGES.
   
   In this issue, in the case of a chart that is not updated, I suggest finding a prop that is not updated case by case and add it to SHOULD_UPDATE_ON_PROP_CHANGES.



##########
superset-frontend/src/dashboard/components/gridComponents/Chart.jsx:
##########
@@ -175,6 +180,11 @@ export default class Chart extends React.Component {
         this.resizeTimeout = setTimeout(this.resize, RESIZE_TIMEOUT);
       }
 
+      if (nextState.isUpdated) {
+        this.setState({ isUpdated: false });

Review Comment:
   It is not recommended to call `setState` in SCU, it is rather hacky. If you want to change state when a prop change, please consider using [static getDerivedStateFromProps](https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org