How to use styles in React.js?

Answer

The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string.
This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes.

const divStyle = {
color: 'blue',
backgroundImage: 'url(' + imgUrl + ')'
};

function HelloWorldComponent() {
return <div style={divStyle}>Hello World!</div>
}
Style keys are camelCased in order to be consistent with accessing the properties on DOM nodes in JavaScript

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---