etr2460 commented on a change in pull request #15891:
URL: https://github.com/apache/superset/pull/15891#discussion_r676702665



##########
File path: superset-frontend/src/SqlLab/components/SqlEditor.jsx
##########
@@ -222,6 +222,15 @@ class SqlEditor extends React.PureComponent {
     });
   }
 
+  static getDerivedStateFromProps(props, state) {
+    if (props.queryEditor.sql !== state.sql) {
+      return {
+        sql: props.queryEditor.sql,
+      };
+    }
+    return null;
+  }

Review comment:
       needing to use this function seems a bit concerning... i'm referencing 
here: 
https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops:
   > If you want to “reset” some state when a prop changes, consider either 
making a component fully controlled or fully uncontrolled with a key instead.
   
   I wonder if we can just use the sql from the `queryEditor` for everything 
here instead of using the `state.sql` string?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to