When I tried to pass a number as argument to function inside JSX the above error occured.
Working file Link : https://codesandbox.io/s/divine-hill-v3gl3?fontsize=14&hidenavigation=1&theme=dark&file=/new.js
React Component.
function Rating(data) {
// This function indent to display number 0 to 3 based on 'data';
switch (data) {
case data <= 0: {
return <div>0</div>;
}
case 0 < data <= 1: {
return <div>1</div>;
}
case 1 < data <= 2: {
return <div>2</div>;
}
case 2 < data <= 3: {
return <div>3</div>;
}
default:
return data;
}
}
function some() {
return (
<div>
<Rating data={product.totalrating} />
</div>
);
}
export default some;