I'm trying to render a component recursively. On each recursive call I subtract 10 px from the dimensions. I expect a series of nested divs, each one 10px smaller. When the height and width reach 10px, the component should return null, so that is my base case.
Instead of expected result, I've got nothing. No errors in the terminal, no errors in the dev tools, just a page that is frozen.
Any thoughts?
RecurentDiv.js:
const RecurentDiv = ({ width, height }) => {
const style = {
width: `${width - 10}px`,
height: `${height - 10}px`,
border: "1px solid black",
display: "inline-block"
};
if (width < 10) return null; //base case
return (
<div style={style}>
<RecurentDiv width={style.width} height={style.height} />
</div>
);
};
export default RecurentDiv;
App.js:
<RecurentDiv width={100} height={100} />