React, Uncaught RangeError: Maximum call stack size exceeded

后端 未结 2 728
感动是毒
感动是毒 2021-01-04 08:40

I\'m working in react and basically I want to make an button with tooltip, right now I\'m making tooltip. I\'m changing css display property in order to make it visible or n

2条回答
  •  迷失自我
    2021-01-04 09:08

    Thanks to @RyanWheale I noticed my mistake.

    In my render function I was returning a button element which called a function which changed a certain state. The returned button looked like this:

    
    

    And my edit function changes some state and looks like this:

    edit: function () {
        this.setState({editing: true});
    }
    

    So, I my mistake is that I, accidentally, typed the parenthesis after this.edit. So, when the button element was being rendered, the edit function was actually called and chaos happened. Now, when I wrote

    instead of

    it worked flawlessly. I hope I help someone save hours of his precious life.

    Cheers :)

提交回复
热议问题