Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
ReactJS Filter Box: Expected an assignment or function call and instead saw an expression no-unused-expressions

I am trying to create a filter Box where the user can filter videos depending on the Language (Hindi, English, Tamil, Malayalam, Arabic and Tagalog). I keep getting this error: Line 42:29: Expected an assignment or function call and instead saw an expression no-unused-expressions. I am trying to understand the error and why does it show. I am getting the error start from the last useEffect that I created until the return statement. Can someone explain the error to me?

Here is my code:

import { useEffect, useState } from "react";
import "./App.css";
import RadioList from "./components/RadioList";

function App() {
  const [data, setData] = useState([]);
  const [filterData, setFilterData] = useState([]);
  const [language, setLangauge] =  useState("");

  useEffect(() => {
    const getData = () => {
      fetch("radio.json", {
        headers: {
          "Content-Type": "application/json",
          Accept: "application/json",
        },
      })
        .then(function (response) {
          console.log(response);
          return response.json();
        })
        .then(function (myJson) {
          console.log(myJson);
          setData(myJson);
        });
    };
    getData();

  }, 
  
  []);
  useEffect(() => {
    setFilterData(data) 



  },
  [data]);

  useEffect(() => {
    setFilterData(
      data.filter(value => {value.language === language})
    )
  },
  [language]);


  return (
    <div className="mt-5 flex flex-col items-center">
       <select
              value="Choose a Language"
        >
      {filterData.map((radioItem) => {
        <option language={radioItem.language}>
      </option>
      })}
       </select>
      {data.map((radioItem) => {
        return (
          <RadioList
            server_url={radioItem.server_url}
            title={radioItem.name}
            language={radioItem.language}
          />
        );
      })}
      
     
    </div>
  );
}

export default App;

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Insert a return statement as follows in your filter inside the useEffect.

useEffect(() => {
  setFilterData(
    data.filter((value) => {
      return value.language === language;
    })
  );
}, [language]);

And you've to do the change given by @J.Parashar as well.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Array.prototype.map() & Array.prototype.filter() expects a return statement, refactoring to below should resolve the issue

{
  filterData.map((radioItem) => {
     return(
          <option> </option>
        )      
   })
}

or simply :

filterData.map(radioItem => (<option>{}</option>)) 

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda