Uncaught ReferenceError: translate is not defined

Viewed 3769
const styles = theme => ({
    imageContent: {
        transform: `${translate('-50%','-50%')}`
    }
});

I want to apply CSS property translate for the div inside a component. So how to refer CSS properties from React Component? Uncaught ReferenceError: translate is not defined.

2 Answers

Suppose you have div:

<div style={{background: white}}> 
   Something
</div>

Also you can initiate a const before:

const styleForaDiv = {background: "white"}
<div style={styleForaDiv}> </div>

Notice that all styles should be camelCased, so background-image turns into backgroundImage and you just use comma inside style dictionary:

const styleForaDiv = {backgroundImage: "url('')", backgroundSize: "cover" }
Related