score:1
Accepted answer
Use react-router-dom
You can use react-router-dom (npm package)
In React Class you can use this:
this.props.history.push('/login')
And in React Hooks you can use useHistory from react-router-dom:
import { useHistory } from "react-router-dom";
export default function SomeFunction() {
const history = useHistory();
const trigerFunction = () => history.push('/login');
return (
<div onClick={trigerFunction}></div>
)
}
BTW
window.location.reload();
it's only refresh the page.
You can save in local storage some that after refresh you know what page to render (but I don't recomend this, and the refresh is unnecessary)
score:0
You can change:
window.location.reload();
this.props.history.push("desired Address");
Source: stackoverflow.com
Related Query
- How do i make a react app redirect to the login page after registration?
- How to I prevent user from accessing the page of my react app directly by entering the URL, and redirect them back to login page
- Redirect user to a page after succesful login in React app
- How can I redirect to previous page after login in react router?
- How to redirect user from login page to another react page if the login was successful?
- How to redirect from login page to home page if the authentication success in react
- React - How can I redirect to another page after some conditions are met on the OnClick of a Button?
- How to redirect to another page after login in react
- How to make a react class component retain its state after login and change available routes based on the state currently available in the component?
- How to redirect to profile page in React after submitting Login and Signup button?
- How to correctly redirect to the login page with React
- How to stay login after refresh the page in react js
- React: How does React make sure that useEffect is called after the browser has had a chance to paint?
- React Flash Message: How to make the message show without refreshing the page but refresh on 200
- How to make a button redirect to another page in React
- How to make the background color of an app cover the entire screen (using style) in React Native?
- How to redirect to login page on click of logout in react
- How do I make a react app in docker-compose? Container is exiting after build steps are complete
- How do I redirect user to another page after submit the form?
- Using React Router to Redirect to next page after successful login
- How to make the react web app full screen
- How to Redirect/go to the User Profile after login page in ReactJS
- Make a new login after the first failure in a React application
- How to update the page after call Axios Successful ? React
- How can I fix the error on my React App after trying to export a functional component?
- How can I on Submit my Form redirect the Results to another Page in React
- How to redirect to a new page in react and typescript after an animation
- How to create login and redirect to another page after success?
- react redirect to another page after login
- How to redirect another page after button on click method react js
More Query from same tag
- Why list disappeared when I remake small part React app to Redux?
- React - Javascript horizontal menu scrolling as you scroll
- React Router v4: Sending requests when navigation changes
- Undefined value after fetching API, React
- Buttons won't render in React after mapping through array
- Typescript Higher Order Component as Decorator
- How to change Material-UI TextField bottom color without using <MuiThemeProvider />
- ASP.Net Core React spa integration test
- React best practice to create modal window
- I want to SetState the items of a child component from the child component to the parent component
- Enzyme - How to access and set <input> value?
- Compiled with warnings. React
- React JSX for loop shows only the last value
- Props aren't passing inside component in test cases written with Jest and Enzyme
- Error with prettier in ReactJS app: Expected atom at position 0
- Unable to display react-toastify
- Is a good practice to create a new React element based on props?
- State is always initial value when attempting to update
- Set active cell when click on it in ReactJs
- React Passing Boolean value to component
- Passing an argument to redux dispatch function
- React Redux createStore Config
- Render Cards after fetch data from api and create an object
- Setting 2 classNames through props
- React filtering a list
- how to toggle class on scroll event in react?
- How do I print the promise value from a post request? (ReactJs)
- Requiring unknown module "498" error in ReactNative getting started example
- How to check if music is playing with Last FM API
- React - How to redirect to url website with attirbut to