I wrote a function that returns some JSX, inside a class component, as follows:
billingPendingMarker = () => {
const { classes } = this.props;
return (
<svg className={classes.marker} height="50px" width="8px">
<rect x="0" width="8" height="50" rx="4" fill={color.reds[300]} />
</svg>
)
}
In the main render method of my class component, I "called" this function as if I were writing JSX:
<this.billingPendingMarker />
While this worked without issues locally, on deploying a build to a staging-environment, I got the following error: https://reactjs.org/docs/error-decoder.html/?args%5B%5D=undefined&args%5B%5D=&invariant=130
When I changed <this.billingPendingMarker />
to this.billingPendingMarker()
my code worked fine. What I can't figure out is, why does writing the "JSX form" cause the page to crash? Are we not, in effect, creating a functional component encapsulated within our main class component?
My initial suspicion was that something was going wrong while the code is minified during the build process, but I'm not sure.
I do understand that this isn't the best "design" practice, but my doubt is more about the correctness of the syntax.
Appreciate any help I can get in understanding this!