@@ -211,23 +211,31 @@ const defaultGetFeatureInfoUrlParameters = {
211211 */
212212const MlWmsLoader = ( props : MlWmsLoaderProps ) => {
213213 // Merge defaults with props using useMemo for stable references
214- // The dependencies are the prop objects - if consumers pass inline objects,
215- // they should memoize them. This follows standard React patterns.
214+ // Use JSON.stringify for stable dependency comparison to prevent reinitialization
215+ // when consumers pass inline objects as props
216+ const baseUrlParametersJson = JSON . stringify ( props . baseUrlParameters ) ;
216217 const baseUrlParameters = useMemo (
217218 ( ) => ( { ...defaultBaseUrlParameters , ...props . baseUrlParameters } ) ,
218- [ props . baseUrlParameters ]
219+ // eslint-disable-next-line react-hooks/exhaustive-deps
220+ [ baseUrlParametersJson ]
219221 ) ;
222+ const getCapabilitiesUrlParametersJson = JSON . stringify ( props . getCapabilitiesUrlParameters ) ;
220223 const getCapabilitiesUrlParameters = useMemo (
221224 ( ) => ( { ...defaultGetCapabilitiesUrlParameters , ...props . getCapabilitiesUrlParameters } ) ,
222- [ props . getCapabilitiesUrlParameters ]
225+ // eslint-disable-next-line react-hooks/exhaustive-deps
226+ [ getCapabilitiesUrlParametersJson ]
223227 ) ;
228+ const getMapUrlParametersJson = JSON . stringify ( props . getMapUrlParameters ) ;
224229 const getMapUrlParameters = useMemo (
225230 ( ) => ( { ...defaultGetMapUrlParameters , ...props . getMapUrlParameters } ) ,
226- [ props . getMapUrlParameters ]
231+ // eslint-disable-next-line react-hooks/exhaustive-deps
232+ [ getMapUrlParametersJson ]
227233 ) ;
234+ const getFeatureInfoUrlParametersJson = JSON . stringify ( props . getFeatureInfoUrlParameters ) ;
228235 const getFeatureInfoUrlParameters = useMemo (
229236 ( ) => ( { ...defaultGetFeatureInfoUrlParameters , ...props . getFeatureInfoUrlParameters } ) ,
230- [ props . getFeatureInfoUrlParameters ]
237+ // eslint-disable-next-line react-hooks/exhaustive-deps
238+ [ getFeatureInfoUrlParametersJson ]
231239 ) ;
232240
233241 const featureInfoSuccessRef = useRef ( props . featureInfoSuccess ) ;
0 commit comments