Skip to content

Commit

Permalink
Remove redundant useeffect
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarx committed Nov 2, 2024
1 parent e378324 commit ac7ef12
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/blocks/venue/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '9d47607a59ae02933048');
<?php return array('dependencies' => array('moment', 'react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '2f49f9baf258110fbb88');
4 changes: 2 additions & 2 deletions build/blocks/venue/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/panels.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '57ffe70d2fa312b2a0da');
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => 'f805b57db54750eb05ac');
4 changes: 2 additions & 2 deletions build/panels.js

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions src/components/VenueInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ const VenueInformation = () => {
[]
);

useEffect(() => {
}, [mapCustomLatLong]);

let venueInformationMetaData = useSelect(
(select) =>
select('core/editor').getEditedPostAttribute('meta')
Expand All @@ -75,6 +72,7 @@ const VenueInformation = () => {
Listener({ setFullAddress, setPhoneNumber, setWebsite });

const updateVenueMetaRef = useRef(updateVenueMeta);

const getData = useCallback(() => {
let lat = null;
let lng = null;
Expand Down Expand Up @@ -108,11 +106,23 @@ const VenueInformation = () => {
});
}
});
}, [fullAddress, mapCustomLatLong, updateVenueMetaRef]);
}, [
fullAddress,
mapCustomLatLong,
updateVenueLatitude,
updateVenueLongitude,
]);

const debouncedGetData = useDebounce(getData, 300);

useEffect(() => {
getData();
}, [getData]);
updateVenueMetaRef.current = updateVenueMeta;
}, [updateVenueMeta]);

useEffect(() => {
debouncedGetData();
}, [fullAddress, debouncedGetData]);

return (
<>
<TextControl
Expand Down

0 comments on commit ac7ef12

Please sign in to comment.