score:1
Accepted answer
in your handlesubmit
function you need to call the handlelogin
from props so the state is correctly updated in your container component.
handlesubmit(event) {
...
.then((response) => {
let token = response.data.access_token;
this.setstate({
redirect: true,
token: token,
loading: false
});
// here, call the handle from props
this.props.handlelogin(token);
}
...
that way, your this.state.authed
will have the proper value
Source: stackoverflow.com
Related Query
- react - react router - privateRoute - infinite loop
- react - react router v6- privateRoute - infinite loop or not rendering
- React Router Redux going back causing an infinite loop
- React router children caught in infinite loop
- Infinite loop with React router
- React Router Redux - Infinite loop when redirecting from IndexRoute
- Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop
- React Router 4.x - PrivateRoute not working after connecting to Redux
- React Hooks useEffect, adding dependency triggers infinite loop
- Infinite loop in React button
- Loop through an array to create routes in react router
- React Redux infinite loop
- React infinite loop dispatch, from useReducer hook
- React setState in promise causing infinite loop
- React infinite loop using componentDidUpdate
- React hooks, set return value of a function to state causes infinite loop
- React onChange stuck in infinite loop
- Infinite loop React hooks
- React Redux: Infinite Loop when dispatch
- Prevent infinite loop when updating state via React useEffect Hook
- React Hooks Exhaustive-deps async infinite Loop
- React UseState hook causing infinite loop
- React useEffect with property as dependency makes infinite loop
- React useEffect() Infinite loop
- Too many re-renders. React limits the number of renders to prevent an infinite loop
- React useEffect infinite loop fetch data axios
- React simple fetch program run into an infinite loop
- Too many re-renders. React Limits the number of renders to prevent an infinite loop - React hooks
- react hooks (useEffect) infinite loop clarification
- react componentdidupdate provokes infinite loop
More Query from same tag
- Protect routes react router dom 6
- Pass this.refs as property in jsx in React.js
- HTML or Script Interpretaion in React and normal HTML
- Deploy Nodejs to Heroku: Error with babel (es6)
- How to set two loops in React JS
- React - async used with componentDidMount()
- How to change border color on focus using styled-components
- Condition on checkbox in React with Redux
- Should we change class component to functional component when we put state into Redux?
- alignment of a tag and p tag not properly centered
- Passing an Object of arrays as a prop in React, then using loops to generate a table with the data
- React-router V-5.2.0 is not working when navigating away from homepage
- Error when running jest on a react native + typescript app (Jest encountered an unexpected token)
- Remove object property based on array values
- Why is my Redux State nested ?
- Add opacity to last visible element in html list
- Fetch never returns data when msw (Mock Service Worker) intercepts request
- Send information from multiple children components to one parent component in React
- How to set CORS headers to a client
- Objects are not valid as a React child . If you meant to render a collection of children, use an array instead
- React keeps throwing index error even though I have indexes defined
- Reactjs - ComponentWillUpdate method not getting executed with enzyme mount
- DELETE returning ERROR 405 (Method not allowed) I'm using React and ASP.net. I don't have a web config file that most people say to edit so I'm lost
- json-server running but can't access its api due to 403
- Install ReactJS on Ubuntu 18.04 -- npm permission denied
- Using React, want to fix useEffect has a missing dependency error
- How to display the title of a component in another component (React.js)?
- how do I modify css in mui components - accordian?
- Manually refresh or re-render component onClick in React
- How to align left for Item1 and align right for Item2 & Item3 with MUI React?