Why I receive this error using componentWillReceiveProps?Why does it give an error in the react lifecycle methods if I am not using them?Why does Google prepend while(1); to their JSON responses?Switch is not render react componentReactJS: Maximum update depth exceeded errorCan't update the state on this React ComponentReact: Maximum update depth exceeded on safariMaximum update depth exceeded - React JsMaximum update depth exceeded using react-selectHow to Maximum update depth exceeded in reactMaximum update depth exceeded. This can happen when a component repeatedly calls setState

Which are more efficient in putting out wildfires: planes or helicopters?

Olive oil in Japanese cooking

Is my background sufficient to start Quantum Computing

What could a Medieval society do with excess animal blood?

Was Wolfgang Unzicker the last Amateur GM?

Performance of loop vs expansion

How should characters be punished for failing faction missions?

Old story where computer expert digitally animates The Lord of the Rings

How frequently do Russian people still refer to others by their patronymic (отчество)?

Can you use a reaction to affect initiative rolls?

SQL Server error 242 with ANSI datetime

What does "another" mean in this case?

How might boat designs change in order to allow them to be pulled by dragons?

Is よう an adjective or a noun?

Does this circuit have marginal voltage level problem?

How come having a Deathly Hallow is not a big deal?

Which high-degree derivatives play an essential role?

Are the plates of a battery really charged?

What is a "tittering order"?

My mother co-signed for my car. Can she take it away from me if I am the one making car payments?

When should we use dependency injection (C#)

Does the North Korea Kim Jong Un have an heir?

A student "completes" 2-week project in 3 hours and lies about doing it himself

Puzzling Knight has a Message for all- Especially Newcomers



Why I receive this error using componentWillReceiveProps?


Why does it give an error in the react lifecycle methods if I am not using them?Why does Google prepend while(1); to their JSON responses?Switch is not render react componentReactJS: Maximum update depth exceeded errorCan't update the state on this React ComponentReact: Maximum update depth exceeded on safariMaximum update depth exceeded - React JsMaximum update depth exceeded using react-selectHow to Maximum update depth exceeded in reactMaximum update depth exceeded. This can happen when a component repeatedly calls setState






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Receive error: ×
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.



Tried to delete part with error and setState (because it looks like the reason of infinite loop). Didn't help



componentWillReceiveProps(nextProps)
if(nextProps.auth.isAuthenticated)
this.props.history.push('/dashboard')

// if(nextProps.errors)
// this.setState(
// errors: nextProps.errors
// )
// console.log('Error');
//
;









share|improve this question



















  • 1





    It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

    – Christopher Ngo
    Mar 25 at 18:13

















1















Receive error: ×
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.



Tried to delete part with error and setState (because it looks like the reason of infinite loop). Didn't help



componentWillReceiveProps(nextProps)
if(nextProps.auth.isAuthenticated)
this.props.history.push('/dashboard')

// if(nextProps.errors)
// this.setState(
// errors: nextProps.errors
// )
// console.log('Error');
//
;









share|improve this question



















  • 1





    It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

    – Christopher Ngo
    Mar 25 at 18:13













1












1








1


1






Receive error: ×
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.



Tried to delete part with error and setState (because it looks like the reason of infinite loop). Didn't help



componentWillReceiveProps(nextProps)
if(nextProps.auth.isAuthenticated)
this.props.history.push('/dashboard')

// if(nextProps.errors)
// this.setState(
// errors: nextProps.errors
// )
// console.log('Error');
//
;









share|improve this question
















Receive error: ×
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.



Tried to delete part with error and setState (because it looks like the reason of infinite loop). Didn't help



componentWillReceiveProps(nextProps)
if(nextProps.auth.isAuthenticated)
this.props.history.push('/dashboard')

// if(nextProps.errors)
// this.setState(
// errors: nextProps.errors
// )
// console.log('Error');
//
;






javascript reactjs react-router infinite-loop






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 20:21









Mis94

1,3641 gold badge11 silver badges27 bronze badges




1,3641 gold badge11 silver badges27 bronze badges










asked Mar 25 at 18:09









Nikita GimonNikita Gimon

111 bronze badge




111 bronze badge







  • 1





    It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

    – Christopher Ngo
    Mar 25 at 18:13












  • 1





    It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

    – Christopher Ngo
    Mar 25 at 18:13







1




1





It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

– Christopher Ngo
Mar 25 at 18:13





It doesn't look like this could be causing the error, could you please post the rest of the code for this component?

– Christopher Ngo
Mar 25 at 18:13












1 Answer
1






active

oldest

votes


















3














history.push causes a rerender, it calls componentWillReceiveProps and everything goes in a loop.



Use this code instead:



componentDidUpdate(prevProps) 
if (
this.props.auth.isAuthenticated
&& this.props.auth.isAuthenticated !== prevProps.auth.isAuthenticated
)
this.props.history.push('/dashboard')




This can still cause a loop if you have a similar mistake somewhere else.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344068%2fwhy-i-receive-this-error-using-componentwillreceiveprops%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    history.push causes a rerender, it calls componentWillReceiveProps and everything goes in a loop.



    Use this code instead:



    componentDidUpdate(prevProps) 
    if (
    this.props.auth.isAuthenticated
    && this.props.auth.isAuthenticated !== prevProps.auth.isAuthenticated
    )
    this.props.history.push('/dashboard')




    This can still cause a loop if you have a similar mistake somewhere else.






    share|improve this answer



























      3














      history.push causes a rerender, it calls componentWillReceiveProps and everything goes in a loop.



      Use this code instead:



      componentDidUpdate(prevProps) 
      if (
      this.props.auth.isAuthenticated
      && this.props.auth.isAuthenticated !== prevProps.auth.isAuthenticated
      )
      this.props.history.push('/dashboard')




      This can still cause a loop if you have a similar mistake somewhere else.






      share|improve this answer

























        3












        3








        3







        history.push causes a rerender, it calls componentWillReceiveProps and everything goes in a loop.



        Use this code instead:



        componentDidUpdate(prevProps) 
        if (
        this.props.auth.isAuthenticated
        && this.props.auth.isAuthenticated !== prevProps.auth.isAuthenticated
        )
        this.props.history.push('/dashboard')




        This can still cause a loop if you have a similar mistake somewhere else.






        share|improve this answer













        history.push causes a rerender, it calls componentWillReceiveProps and everything goes in a loop.



        Use this code instead:



        componentDidUpdate(prevProps) 
        if (
        this.props.auth.isAuthenticated
        && this.props.auth.isAuthenticated !== prevProps.auth.isAuthenticated
        )
        this.props.history.push('/dashboard')




        This can still cause a loop if you have a similar mistake somewhere else.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 18:21









        UjinT34UjinT34

        2,3951 gold badge3 silver badges16 bronze badges




        2,3951 gold badge3 silver badges16 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344068%2fwhy-i-receive-this-error-using-componentwillreceiveprops%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript