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

177
Vistas
how to change the react component css class value

Here is my 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;

my css file where the player css is defined

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

Here what i want now by using the moveRight function i want to manipulate the value of player class grid-row-start and grid-column-start how can i achive this

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

0

You can use inline styling and pass your variables directly

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

Please keep in mind that in your case you will need to pass cordinates down to Player component as a props and then use inline styling accordingly

about 4 years ago · Juan Pablo Isaza Denunciar

0

you can use styledcomponent for this situation

but you can do it in your js file too you should use inline style on the jsx tag like this

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 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