score:1
Accepted answer
so after talking about it for a bit. figured out what you were wanting to do.
you need to define a new route in react-router that you can use for this history change.. something like this:
<route exact path="/:name" component={somecomponent} />
in your component you have access to this "name" via this.props.params.name
you can also call an action to update the store before updating this route
note: if you stay with v2... you should make your actions return a promise, so that you can just chain the event in your component. aka:
onchange={this.handlechange}
handlechange = (value) => { // assuming you have the value here.. it may be e is the function param and you get the value as e.target.value
this.props.saveselectedanimal(value).then( () => {
this.props.history.push("/");
})
}
Source: stackoverflow.com
Related Query
- Navigate to a different route programmatically
- How to navigate to different route programmatically in `redux-router5`?
- How to route to or navigate to a route programmatically in nextjs class component?
- React BrowserRouter - how to programmatically navigate to different routes?
- How do I navigate to a different route in my react application?
- How I navigate to the different routes when I am on the certain Route
- How to navigate into different component from nested route in React?
- Programatically navigate to a different route and pass query
- Programmatically navigate to server page if route is not found
- Changing route programmatically with two different props types
- Programmatically navigate using React router
- Programmatically navigate using react router V4
- Programmatically Navigate using react-router
- using same component for different route path in react-router v4
- Navigate to different screen from a button in a header
- React Router v4 - Redirect to same route with different query params
- Using React.js lazy loading when I navigate to a nested route the main bundle doesn't load
- Uncaught TypeError: (0 , _reactRouter.withRouter) is not a function when navigating to route programmatically in react-router 2.4.0
- Programmatically Navigate w/ HashRouter
- Ingress route - path based routing to different React app
- Cannot render same route with different parameters react router v4
- Changing route parameters when a different dropdown option is selected in React
- Problem in redirecting programmatically to a route in react router v6
- React-router 2.0: programmatically change route (URL not updated)
- How do I programaticly navigate to a route from an event handler in React Router 4.0?
- What is the different between Router vs Route in react-router-dom
- How to navigate between different nested stacks in React Navigation 5.x?
- React Redux with redux-observable use the router to navigate to a different page after async action complete
- React-Router: Apply logic to component before navigating to a different route
- ClickAwayListener doesn't fire when clicking on a link/button to navigate to other route
More Query from same tag
- Getting a return value from axios function in reactJS
- Preserve type argument in Redux connected component
- 'useState' is not defined no-undef React
- It is better bind methods in the constructor of a component or in the render method?
- Firebase auth custom claims causes issues with loader
- Problems with path variable in Spring Boot + React
- ESLint configuration for JSX
- Pass parameters to Firebase cloud function
- Manual DOM updates and React Component Rendering using forceUpdate()
- Get size of array returned by map in React render
- React custom hooks and useMemo hooks
- I want the image to change when i click the button in class component React JS
- Storing JSX code for late rendering
- React Using Hooks and Context without re-renders of a component that uses only uses the setter function
- Invalid input file upload api platform
- Infinite Loop When Using Hooks in React
- How to navigate after submit radio form in ReactJs
- webpack sass-loader not generate class selectors styles
- styling ant design tab header to look like radio buttons
- React pushing array to state
- My useState hook isn't working in a specific portion of my code, but it's working everywhere else. Why is this happening despite using identical code?
- How to make an input field
- Discriminate Union doesn't work for function argument
- mapStateToProps returns undefined
- How do you test temporary loading text with react testing library?
- How to give styling to components different than App.css in react?
- Mutation error when saving redux store. All copied and saved
- unable to uncheck and check single item
- What exactly is a Typography component in React?
- React hooks app saga use history.push then doesn't render component correctly