Skip to content

Commit

Permalink
Merge pull request #976 from kartoza/use-local-variables-for-long-and…
Browse files Browse the repository at this point in the history
…-lat

patch: assign update value to fields
  • Loading branch information
tinashechiraya authored Apr 11, 2024
2 parents fd40100 + 466a8b8 commit 42b3c00
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface DegreeInputInterface {

/** Degree input form. **/
function DegreeInput({ label, value, onChange, disabled }: DegreeInputInterface) {
console.log('curr value from use state: ',value)
const [currValue, setCurrValue] = useState(value)
const min = label === 'Latitude' ? -90.000000 : -180.000000;
const max = -1 * min;
Expand All @@ -36,10 +35,11 @@ function DegreeInput({ label, value, onChange, disabled }: DegreeInputInterface)


useEffect(() => {
console.log('currValue : ',value)
if (!isNaN(currValue)) {
onChange(currValue)
if (!isNaN(value)) {
console.log('assigning value ',value)
onChange(value)
}
setCurrValue(value)
}, [value,currValue]);

return <div
Expand Down Expand Up @@ -160,11 +160,11 @@ export default function DegreeInputs(
}, [longitude]);

// useEffect to log changes in latitude, longitude, and disabled props
useEffect(() => {
console.log('Latitude:', localLatitude);
console.log('Longitude:', localLongitude);
console.log('Disabled:', disabled);
}, [localLatitude, localLongitude, disabled]);
// useEffect(() => {
// console.log('Latitude:', localLatitude);
// console.log('Longitude:', localLongitude);
// console.log('Disabled:', disabled);
// }, [localLatitude, localLongitude, disabled]);

return <>
<DegreeInput
Expand Down

0 comments on commit 42b3c00

Please sign in to comment.