eschutho commented on a change in pull request #12873:
URL: https://github.com/apache/superset/pull/12873#discussion_r569786450
##########
File path: superset-frontend/src/SqlLab/components/TemplateParamsEditor.jsx
##########
@@ -68,23 +60,26 @@ export default class TemplateParamsEditor extends
React.Component {
} catch (e) {
isValid = false;
}
- this.setState({ parsedJSON, isValid, codeText });
+ setState({ parsedJSON, isValid, codeText });
const newValue = isValid ? codeText : '{}';
- if (newValue !== this.props.code) {
- this.props.onChange(newValue);
+ if (newValue !== code) {
+ onChange(newValue);
}
- }
+ };
+
+ useEffect(() => {
+ onChange(codeText);
+ }, [codeText]);
Review comment:
don't think you need this useEffect either. The component will
automatically update state if the codeText is changed in either setState or
from the props.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]