4

I have these css

transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);

Now I want to move this to CSS in JS ReactJS style

const useStyles = makeStyles({
  transform: "translate(-50%, -50%)",
  -webkit-transform: "translate(-50%, -50%)",
  -ms-transform: "translate(-50%, -50%)"

However it can not be compiled

/src/views/LandingPage.js
  Line 85:5:  Parsing error: Unexpected token

  84 |     transform: "translate(-50%, -50%)",
> 85 |     -webkit-transform: "translate(-50%, -50%)",
     |     ^
  86 |     -ms-transform: "translate(-50%, -50%)"

How can I fix this??

1 Answer 1

4

The Material UI makeStyles() accepts a normal JS object, so you can define the key using a string:

const useStyles = makeStyles({
myStyle:{
  "transform": "translate(-50%, -50%)",
  "-webkit-transform": "translate(-50%, -50%)",
  "-ms-transform": "translate(-50%, -50%)"
}
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.