{"size": 939, "ext": "js", "max_stars_repo_path": "src/components/Country/Country.js", "max_stars_repo_name": "savasdd/react-js-covid19", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/Country/Country.js", "max_issues_repo_name": "savasdd/react-js-covid19", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Country/Country.js", "max_forks_repo_name": "savasdd/react-js-covid19", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.4545454545, "max_line_length": 89, "alphanum_fraction": 0.5623003195}
import React, {useEffect, useState} from "react";
import {fetchCountry} from "../../util";
import {useDispatch, useSelector, connect} from "react-redux";
import {grafigDegistir} from "../../store/Action";

const Country = ({coutryChange}) => {
    const [countries, setCountries] = useState([]);

    useEffect(() => {
        const getCountry = async () => {
            setCountries(await fetchCountry());
        };
        getCountry();
    }, [setCountries]);

    const dispatch = useDispatch();
    const change = (e) => {
        e.preventDefault();
        dispatch(grafigDegistir(e.target.value));
    };

    return (
        <div className="country">
            <select className="form-control form-control-sm" onChange={(e) => change(e)}>
                <option></option>
                {countries.map((x, i) => <option key={i} value={x}>{x}</option>)}
            </select>
        </div>
    )


}
export default Country;