Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop

后端 未结 5 582
小鲜肉
小鲜肉 2020-12-08 18:29

I\'m trying to add a snackBar in order to display a message whenever a user signIn or not. SnackBar.jsx:

import React from \"react\";
import PropTypes from \         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 19:06

    You must link an event in your onClick. Additionally, the click function must receive the event. See the example

    export default function Component(props) {
    
        function clickEvent (event, variable){
            console.log(variable);
        }
    
        return (
            
    clickEvent(e, 10)} >
    ) }

提交回复
热议问题