-3

I got some error when using inline style in react js and I don't know what's mean enter image description here

I think using brackets in inline style, for instance, would work,

2
  • remove the semicolon before Transition, make all values strings Commented Nov 26, 2017 at 17:02
  • Possible duplicate of React.js inline style best practices Commented Nov 28, 2017 at 7:17

1 Answer 1

4

The React style prop requires a valid javascript object with camelCased property names. The values in the key value pair can be a number or a string (or a variable representing one of those 2 items). See React Docs for more information.

A style object would look like:

const style = { 
      transform: "translate3d(0px, 0px, 0px)", 
      transition: "0s"
    }

Notice that there are no semi-colons, the values are strings and each css property/value is separated by commas.

Note: you can pass numbers for pixel based values and React will add the "px" for you. However in the case above for the 0px it won't work as it is part of a string and not just a simple number.

try:

style={{ transform: "translate3d(0px, 0px, 0px)", transition: "0s"}}

or, using the var I created above:

style={style}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot sir ,

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.