javascriptreactjsreact-hooksreact-table-v7

Variable is not being set in use State


const DonorsTables = () =>{
  const [search, setSearch] = useState("");
  const [countries, setCountries] = useState([]);
  const [filteredcountries, setFilteredCountries] = useState([]);
 

  const getCountries = async () => {
    try {
      const response = await axios.get("https://restcountries.com/v2/all");
      setCountries = (response.data);
      setFilteredCountries = (response.data);
    } catch (error) {
      console.log(error)
      console.log("Not Data Found")
    }
  };

And in the console I am getting this no Data found..... Also, I am getting the warning that setCountries is defined but its value is never used. And an Error of assignment to a constant variable error in setCountries = (response.data);

I want to diplay the list of countries on my screen


Solution

  • setCountries and setFilteredCountries are functions

      setCountries(response.data);
      setFilteredCountries(response.data);