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

186
Views
cómo cambiar el valor de la clase css del componente de reacción

Aquí está mi App.js

 import './App.css'; import './scripts/logic.js'; import Player from './components/Player' import { useState } from 'react' function App() { const [cordinate,setCordinate] = useState({x:"",y:""}) function moveRight(){ } return ( <div className="App"> <div className="container"> <div className="board" id="board"> <Player/> </div> <button>Move Right</button> </div> </div> ); } export default App;

mi archivo css donde se define el jugador css

 .player{ background-color: red; grid-row-start: 5; grid-column-start:5; }

Aquí lo que quiero ahora usando la función moveRight quiero manipular el valor de la clase de jugador grid-row-start y grid-column-start ¿cómo puedo lograr esto?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede usar estilos en línea y pasar sus variables directamente

 <div className="container" style={{gridRowStart: cordinate.x, gridRowEnd: cordinate.y}}>

Tenga en cuenta que, en su caso, deberá pasar las coordenadas al componente Player como accesorios y luego usar el estilo en línea en consecuencia.

about 4 years ago · Juan Pablo Isaza Report

0

puede usar styledcomponent con estilo para esta situación

pero también puede hacerlo en su archivo js, debe usar el estilo en línea en la etiqueta jsx como esta

 const [cordinate,setCordinate] = useState({x:"",y:""}) function moveRight(){ // change your state over here } const tagStyle = { gridRowStart: cordinate.x, gridColumnStart: cordinate.y , } <tag style={tagStyle}> ... </tag>
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!