Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Uncaught Error: Too many re-renders

// TLDR dont call setState in the wrong places 
// or use () => functionX() inside of onChange or similar

const SingInContainer = ({ message, variant}) => {
    const [open, setSnackBarState] = useState(false);
    const handleClose = (reason) => {
        if (reason === 'clickaway') {
          return;
        }
        setSnackBarState(false)

      };

    if (variant) {
        setSnackBarState(true); // HERE BE DRAGONS
    }
    return (
        <div>
        <SnackBar
            open={open}
            handleClose={handleClose}
            variant={variant}
            message={message}
            />
        <SignInForm/>
        </div>
    )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Uncaught #Too
ADD COMMENT
Topic
Name
6+6 =