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

135
Views
Variable indefinida usando .map() reaccionar

Estoy revisando un proyecto anterior para un curso en la escuela, pero sigo recibiendo un error de una variable de cuadrícula indefinida para generar mi cuadrícula.

Quiero recorrer la cantidad de filas y columnas para las que quiero almacenar las propiedades en una matriz llamada cuadrícula. Luego, quiero mostrar nodos para las filas y columnas en la matriz con .map().

Sin embargo, soy bastante nuevo para reaccionar y parece que no puedo encontrar por qué no puedo acceder a la matriz de cuadrícula dentro de render().

 class PathfinderGrid extends Component { constructor(props) { super(props) this.state = { grid: [], }; } componentDidMount() { const grid = createGrid(); this.setState({ grid }); //console.log(this.state.grid) } render() { return ( <div> {grid.map((grid) => { <div>{ grid }</div> })} </div > ); } } const createGrid = () => { let grid = []; for (let row = 0; row < 15; row++) { let currentRow = []; for (let col = 0; col < 50; col++) { currentRow.push(); } grid.push(currentRow); //console.log(grid); } return grid; }; export default PathfinderGrid;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como está utilizando el componente de clase, creo que necesita escribir

 {this.state.grid.map((grid) => { return <div>{ grid }</div> })}
about 4 years ago · Juan Pablo Isaza Report
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!