Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  23] [ 2]  / answers: 1 / hits: 47338  / 4 Years ago, sat, april 25, 2020, 12:00:00

I am trying to set a style for a component, but I do not know how to write the correct syntax in React. My CSS looks like this:



 .cell {
border: 1px solid rgba(0, 0, 0, 0.05);
}


And here is my render() method:



 render() {
let styles = {
...

//border: 1px solid rgba(0, 0, 0, 0.05), <---- Not correct
};
return (
<div className=cell style={styles}></div>
);
}


How do I convert the CSS syntax into a React/JS syntax ?


More From » reactjs

 Answers
8

Here is the thing:



render() {
const styles = {
border: '1px solid rgba(0, 0, 0, 0.05)',
};

return (
<div style={styles}>Hello</div>
);
}

[#51003] Thursday, April 16, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocioblancac

Total Points: 699
Total Questions: 96
Total Answers: 108

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
;