react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Uncaught TypeError: Cannot read properties of undefined (reading 'trim')

Open vitalijalbu opened this issue 4 years ago • 3 comments

Issue template

Uncaught TypeError: Cannot read properties of undefined (reading 'trim') I got this error on Autocomplete input component. here's my code

import React, { useRef, useState } from 'react';
import { Autocomplete } from '@react-google-maps/api';


const AddressField = ({ label, name, placeholder, required, readOnly, initialValue }) => {
  const [value, setValue] = useState(initialValue);
  const addressRef = useRef();

  const handelChange = () => {
    if (addressRef.current !== null) {
      const { formatted_address } = addressRef.current.getPlace();
      setValue(formatted_address);
    }
  };

  return (
    <div>
    {label ? (<p>{label}</p>) : null}
    <Autocomplete onLoad={(ref) => (addressRef.current = ref)} onPlaceChanged={handelChange}>
      <input name={name} placeholder={placeholder} required={required} readOnly={readOnly} value={value} />
    </Autocomplete>
  </div>
  );
};

export default AddressField;

Your Environment

os: mac

node --latest

react version --latest

webpack version --latest

@react-google-maps/api 2.7.0

vitalijalbu avatar Nov 17 '21 10:11 vitalijalbu

@vitalijalbu please provide minimal reproduction in codesandbox.io

JustFly1984 avatar Apr 29 '22 16:04 JustFly1984

sorry, will provide asap. it. was long time ago :D

vitalijalbu avatar Apr 29 '22 20:04 vitalijalbu

@JustFly1984 can i take up this issue?

VivekModiya avatar Sep 06 '23 07:09 VivekModiya