Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 6597 | Rev 7124 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6597 Rev 7122
Línea 1... Línea 1...
1
import React, { useState, useEffect, useRef } from "react";
1
import React, { useEffect, useRef } from "react";
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
let autoComplete;
3
let autoComplete;
4
 
4
 
Línea 37... Línea 37...
37
    const query = addressObject.formatted_address;
37
    const query = addressObject.formatted_address;
38
    updateQuery(query);
38
    updateQuery(query);
39
    console.log(addressObject);
39
    console.log(addressObject);
40
}
40
}
Línea 41... Línea 41...
41
 
41
 
42
function SearchLocationInput({googleApiKey}) {
-
 
43
    const [query, setQuery] = useState("");
42
function SearchLocationInput({ googleApiKey, setValue, value }) {
Línea 44... Línea 43...
44
    const autoCompleteRef = useRef(null);
43
    const autoCompleteRef = useRef(null);
45
 
44
 
46
    useEffect(() => {
45
    useEffect(() => {
47
        loadScript(
46
        loadScript(
48
            `https://maps.googleapis.com/maps/api/js?key=${googleApiKey}&libraries=places`,
47
            `https://maps.googleapis.com/maps/api/js?key=${googleApiKey}&libraries=places`,
49
            () => handleScriptLoad(setQuery, autoCompleteRef)
48
            () => handleScriptLoad(setValue, autoCompleteRef)
Línea 50... Línea 49...
50
        );
49
        );
51
    }, []);
50
    }, []);
52
 
51
 
53
    return (
52
    return (
54
        <div className="search-location-input">
53
        <div className="search-location-input">
55
            <input
54
            <input
56
                ref={autoCompleteRef}
55
                ref={autoCompleteRef}
57
                onChange={event => setQuery(event.target.value)}
56
                onChange={event => setValue(event.target.value)}
58
                placeholder="Enter a City"
57
                placeholder="Enter a City"
59
                value={query}
58
                value={value}
60
            />
59
            />