I wrote this code which works
function Circle(props) {
var style = {
backgroundColor: "white",
border: "1px solid black",
borderRadius: "100%",
paddingTop: "98%"
}
return (<div style={style}></div>)
}
But I want to write it as a class component so I tried
class Circle extends React.Component {
var style = {
backgroundColor: "white",
border: "1px solid black",
borderRadius: "100%",
paddingTop: "98%"
};
render() { return(
<div style={style}></div>
)}
}
The error I get is
SyntaxError: Inline Babel script: Unexpected token, expected ( (3:13)
1 |
2 | class Circle extends React.Component {
> 3 | var style = {
I googled a fair amount and found articles like these
Based on this I tried various keywords like static cost and let but nothing seems to work.
Coming from java world, why can't I have the style as the property of my class?
don't flame me I just started to learn react and I did google before asking.
rendervaris not valid ins a class definition.