Closed teddyboirin closed 2 years ago
@teddyboirin Hey, I believe it's the ({ ...form, ... })
that basically is empty. You can just change a single state inside the onPlaceSelected
callback hence making it more isolating. onPlaceSelected: (places) => { setFieldValue('myPlace', places: places.address_components[2].long_name) }
Hello! i don't know why but my previous state (others input) are removed when I use usePlacesWidget :
const { ref } = usePlacesWidget({ apiKey: 'api', onPlaceSelected: (places) => { setForm({ ...form, city: places.address_components[2].long_name, postcode: places.address_components[6].long_name, }); }, language: 'fr', options: { types: ['address'], componentRestrictions: { country: 'fr' }, }, });