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;
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
add a comment |
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
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
add a comment |
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
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
javascript reactjs react-router infinite-loop
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 25 at 18:21
UjinT34UjinT34
2,3951 gold badge3 silver badges16 bronze badges
2,3951 gold badge3 silver badges16 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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