Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
reaccionar estado obtener objeto específico de matriz con estado a otro componente

Soy nuevo en reaccionar y necesito aprender algunas cosas. Necesito saber si mi forma de obtener una película específica es correcta (funciona, pero creo que no es la forma correcta). Tengo un estado de datos. Necesito obtener un objeto específico. dentro de la matriz y este objeto se mostrará en el componente "spesificMovie", así que para obtener el objeto correcto, creo una función que se ejecuta con filtro en el estado con datos y luego busca si el nombre es igual al nombre que le doy a la función como argumento. devolverá el objeto a otro estado que será spesificMovie y este estado lo muevo al componente spesificMoive

 import { useState } from "react"; import Movie from "./componente/Movie"; import SpesificMovie from "./componente/SpesificMovie"; function App() { const [spesificMovie, setSpesificMovie] = useState(); const getMovieFunc = (name) => { movies.filter((movie) => { if (movie.movieName == name) return setSpesificMovie(movie); }); }; const [movies, setMovies] = useState([ { movieName: "godfather", info: "the rise of corelone family all mater is respect,money,woman but the youngest son michal has a diffrent plans...", picture: "pictures/godfather.jpg", rating: [10, 5, 1], }, { movieName: "scarface", info: "the rise of tony montata the badass man of miami want to control miami and be the number 1 of the cocaine provider ...", picture: "pictures/scarface.jpg", rating: [10, 9, 2], }, { movieName: "the-dark-knight", info: "you all knew that he will come the batman! come to fight with his popular rival the joker...", picture: "pictures/the-dark-knight-poster.jpg", rating: [10, 10, 9], }, ]); return ( <div className="App"> <SpesificMovie spesificMovie={spesificMovie}/> <Movie movies={movies} getMovieFunc={getMovieFunc}/> </div> ); } export default App;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!