Reactjs State error

I’m getting this error in the browser when I try and set the state interval to update my prices. No compilation errors were thrown in the console.

“Received NaN for the children attribute. If this is expected, cast the value to a string.”

componentDidMount() {

const callback = () =>  {
const randomPercentage = 0.995 + Math.random() * 0.01;
this.setState(function(oldState) {
    return {
        price: oldState.price * randomPercentage
setInterval(callback, 1000);


Hi @kmatth007,

Probably it is a run time warning. I cannot understand or debug your code with only one specific snippet of code. Since React has a lot of moving parts, it only helps when you share most of the code with us. Or better yet, the entire repository.

Happy learning!

Thank Malik I figured it out. I did not have the props set correctly. I had price =“10000” instead of price= {10000} so it was trying to do the math calculation on a string and not a number.

1 Like

Awesome. Keep up the good work mate.