score:0
instead of relying on the previous url, you can add a state
object to the location descriptor when you are redirecting.
function redirectaftersignin() {
const {
nextpath,
join = false
} = this.props.location.query
this.router.push({
pathname: nextpath,
state: { join }
})
}
then in your other component, you will just need to check the location.state
prop to determine the join
value.
class mycomponent extends react.component {
componentwillreceiveprops(nextprops) {
if (nextprops.location.state.join) {
// do something
}
}
}
Source: stackoverflow.com
Related Query
- Call a method on componentWillReceiveProps based on previous path url
- How to update ReactJS component based on URL / path with React-Router
- componentWillReceiveProps method doesn't run anymore when using redux to call api
- NextJS: Axios or Fetch post and get method result wrong URL path api
- Can't call object method on previous state in setState hook inside subscribe body
- Filter a list of items based on URL path
- ReactJS/ React-Router: How to filter nested array and objects based on url path parameters?
- conditionally render different method in react component based on URL
- How to create a condition based on URL path with React?
- how to detect previous url path react
- How to dynamically render content based on object property and path in url
- React-Redeux | Can i call connect method of react-redux based upon the condition
- Call method from child (class based component) in parent (functional component)
- Call child method from parent
- ReactJS call parent method
- How to use lifecycle method getDerivedStateFromProps as opposed to componentWillReceiveProps
- Call a React component method from outside
- Call a React component method from outside
- Detect previous path in react router?
- ReactJS - Call One Component Method From Another Component
- Asynchronous call in componentWillMount finishes after render method
- react routing is able to handle different url path but tomcat returns 404 not available resources
- How can I call parent method in a child React component?
- How can I call method from onPress on Alert function [React-Native]
- Load images based on dynamic path in ReactJs
- Redirect to previous path on login - React Router v4
- How do I call a method from another class component in React.js
- Webpack loads from the wrong URL when the path changes
- Webpack [url/file-loader] is not resolving the Relative Path of URL
- Is it safe to call react hooks based on a constant condition?
More Query from same tag
- ReactJS Cannot read property 'map' of undefined
- Component getting redux state asynchronously?
- Not able to add my provider in side the index.js file in reactjs
- React router get currently active segment as param
- How to test Parent passing `this` to Children using enzyme
- How to show submitted data in React immediately, without refreshing the page?
- What is the equivalent to ng-if in react.js?
- Adding Font Awesome Pro to React App - getting started
- React how to add counter in useCallback
- Why is React component rerendering when props has not changed?
- How to make a production build of React app with a custom mode?
- How do I make parent component stay while switching between other components in react router v6?
- How to redirect on button click to another page
- How to open a specific popup on map load?
- ReactJs prevent e and dot in an input type number
- Wrap flex child element in a way that each row has 3 child elements
- How to mock an api for a React stateless functional component?
- Redux shows incorrect negative value for cost of items
- How to prevent rollup from looking in parent node_modules folder
- Creating Generic React Function Component With Type That Ensures Presence of a Property
- How to ı use function for the only localstorage events, without component?
- New React project 2.1 fails with NPM ERR! 418 I'm a teapot
- React webpack proxy cors issue when calling the api
- Binding multipal row hang or crash web page using React with redux toolkit
- Add CSS style using className in Material UI component coming from dynamic json object in ReactJS
- Visual Studio Code unbound breakpoint Node JS React TypeScript
- Why react `useRef` hook stores the objects in `current` property? Why cant it store directly in the ref object?
- Is it posible to sync latest state in function
- How to render all object properties from array of objects
- Why is react router throwing 'Cannot GET /example' error?