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

129
Vistas
Filter in Javascript not filtering

I am making a tour website using React as practice where a couple of locations with their images, descriptions as well as prices are presented and a button is added on each location where it removes a location from the site.

The function passed to the button is 'handleRemoval' whose code is as follows:

import { useState } from 'react';
import './App.css';
import Tours from'./tours.js'
import datas from './toursData.js'

function App() {

  const [locations, setLocations] = useState([datas])

  const handleRemoval = (id) =>{
  const newLocations = locations.filter(location => location.id !== id);
  console.log(newLocations); //checking whether locations is filtered
  setLocations(newLocations);
}
return (
    <Tours tours={datas} handleRemoval={handleRemoval}/>
);
}

When I click the button and check the console I find that locations is not filtered and I don't understand why pls help :(

Github also happens to be showing errors so if you need the full code I'll just send it to you

about 4 years ago · Juan Pablo Isaza
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