@@ -24,6 +24,7 @@ import {
2424import { JsonArray , JsonValue , t } from '@superset-ui/core' ;
2525import { ControlProps } from 'src/explore/components/Control' ;
2626import builtInControlComponents from 'src/explore/components/controls' ;
27+ import useEffectEvent from 'src/hooks/useEffectEvent' ;
2728
2829/**
2930 * Full control component map.
@@ -72,7 +73,7 @@ export type AsyncVerify = (
7273 * Whether the extra props will update the original props.
7374 */
7475function hasUpdates (
75- props : ControlPropsWithExtras ,
76+ props : Partial < ControlPropsWithExtras > ,
7677 newProps : ExtraControlProps ,
7778) {
7879 return (
@@ -165,17 +166,17 @@ export default function withAsyncVerification({
165166 [ basicOnChange , otherProps , verifiedProps ] ,
166167 ) ;
167168
168- useEffect ( ( ) => {
169- if ( needAsyncVerification && verify ) {
169+ const verifyProps = useEffectEvent (
170+ ( verifyFunc : AsyncVerify , props : typeof otherProps ) => {
170171 if ( showLoadingState ) {
171172 setIsLoading ( true ) ;
172173 }
173- verify ( otherProps )
174+ verifyFunc ( props )
174175 . then ( updatedProps => {
175176 if ( showLoadingState ) {
176177 setIsLoading ( false ) ;
177178 }
178- if ( updatedProps && hasUpdates ( otherProps , updatedProps ) ) {
179+ if ( updatedProps && hasUpdates ( verifiedProps , updatedProps ) ) {
179180 setVerifiedProps ( {
180181 // save isLoading in combination with other props to avoid
181182 // rendering twice.
@@ -198,14 +199,14 @@ export default function withAsyncVerification({
198199 ) ;
199200 }
200201 } ) ;
202+ } ,
203+ ) ;
204+
205+ useEffect ( ( ) => {
206+ if ( needAsyncVerification && verify ) {
207+ verifyProps ( verify , otherProps ) ;
201208 }
202- } , [
203- needAsyncVerification ,
204- showLoadingState ,
205- verify ,
206- otherProps ,
207- addWarningToast ,
208- ] ) ;
209+ } , [ needAsyncVerification , verify , otherProps , verifyProps ] ) ;
209210
210211 return (
211212 < ControlComponent
0 commit comments