1- import react , { useMemo } from 'react' ;
1+ import {
2+ useCallback ,
3+ useMemo ,
4+ useState ,
5+ } from 'react' ;
26import { useOutletContext } from 'react-router-dom' ;
37import {
48 ArtboardLineIcon ,
@@ -132,7 +136,7 @@ function LocalUnitsMap(props: Props) {
132136 pageSize : 9999 ,
133137 } ) ;
134138
135- const urlQuery = react . useMemo < GoApiUrlQuery < '/api/v2/public-local-units/' > > (
139+ const urlQuery = useMemo < GoApiUrlQuery < '/api/v2/public-local-units/' > > (
136140 ( ) => ( {
137141 limit,
138142 type__code : filter . type ,
@@ -183,11 +187,11 @@ function LocalUnitsMap(props: Props) {
183187 const [
184188 clickedPointProperties ,
185189 setClickedPointProperties ,
186- ] = react . useState < ClickedPoint | undefined > ( ) ;
190+ ] = useState < ClickedPoint | undefined > ( ) ;
187191
188- const [ loadedIcons , setLoadedIcons ] = react . useState < Record < string , boolean > > ( { } ) ;
192+ const [ loadedIcons , setLoadedIcons ] = useState < Record < string , boolean > > ( { } ) ;
189193
190- const handleIconLoad = react . useCallback (
194+ const handleIconLoad = useCallback (
191195 ( loaded : boolean , key : string ) => {
192196 setLoadedIcons ( ( prevValue ) => ( {
193197 ...prevValue ,
@@ -197,7 +201,7 @@ function LocalUnitsMap(props: Props) {
197201 [ ] ,
198202 ) ;
199203
200- const allIconsLoaded = react . useMemo (
204+ const allIconsLoaded = useMemo (
201205 ( ) => (
202206 Object . values ( loadedIcons ) . filter ( Boolean ) . length === sumSafe ( [
203207 localUnitsOptions ?. type . length ,
@@ -207,7 +211,7 @@ function LocalUnitsMap(props: Props) {
207211 [ loadedIcons , localUnitsOptions ] ,
208212 ) ;
209213
210- const localUnitPointLayerOptions : Omit < CircleLayer , 'id' > = react . useMemo ( ( ) => ( {
214+ const localUnitPointLayerOptions : Omit < CircleLayer , 'id' > = useMemo ( ( ) => ( {
211215 layout : {
212216 visibility : 'visible' ,
213217 } ,
@@ -236,8 +240,10 @@ function LocalUnitsMap(props: Props) {
236240 } ,
237241 } ) , [ localUnitsOptions ] ) ;
238242
239- const countryBounds = react . useMemo ( ( ) => (
240- countryResponse ? getBbox ( countryResponse . bbox ) : undefined
243+ const countryBounds = useMemo ( ( ) => (
244+ ( countryResponse && countryResponse . bbox )
245+ ? getBbox ( countryResponse . bbox )
246+ : undefined
241247 ) , [ countryResponse ] ) ;
242248
243249 const {
@@ -276,7 +282,7 @@ function LocalUnitsMap(props: Props) {
276282 ? publicLocalUnitDetailError
277283 : superLocalUnitDetailError ;
278284
279- const localUnitsGeoJson = react . useMemo < GeoJSON . FeatureCollection < GeoJSON . Geometry > > (
285+ const localUnitsGeoJson = useMemo < GeoJSON . FeatureCollection < GeoJSON . Geometry > > (
280286 ( ) => ( {
281287 type : 'FeatureCollection' as const ,
282288 features : localUnits ?. results ?. map (
@@ -305,7 +311,7 @@ function LocalUnitsMap(props: Props) {
305311 [ localUnits ] ,
306312 ) ;
307313
308- const handlePointClick = react . useCallback (
314+ const handlePointClick = useCallback (
309315 ( feature : mapboxgl . MapboxGeoJSONFeature , lngLat : mapboxgl . LngLat ) => {
310316 setClickedPointProperties ( {
311317 id : feature . properties ?. id ,
@@ -317,14 +323,14 @@ function LocalUnitsMap(props: Props) {
317323 [ setClickedPointProperties ] ,
318324 ) ;
319325
320- const handlePointClose = react . useCallback (
326+ const handlePointClose = useCallback (
321327 ( ) => {
322328 setClickedPointProperties ( undefined ) ;
323329 } ,
324330 [ setClickedPointProperties ] ,
325331 ) ;
326332
327- const emailRendererParams = react . useCallback (
333+ const emailRendererParams = useCallback (
328334 ( _ : string , email : string ) : LinkProps => ( {
329335 className : styles . email ,
330336 withUnderline : true ,
0 commit comments