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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현