score:3
Accepted answer
The useMutation
hook returns some boolean variables you can use.
const mutation = useMutation(deleteInvoice, {
onSuccess: () => {
queryClient.invalidateQueries("invoices");
},
});
const removeInvoice = () => {
mutation.mutate(id)
}
if (mutation.isSuccess) {
return <Redirect to='/' />
}
return (
....
)
Source: stackoverflow.com
Related Query
- How to redirect to homepage using React Router and React Query
- Using React Router and Webpack 2 how to require external libraries only on certain routes?
- How to intercept back button in a React SPA using function components and React Router v5
- How to redirect to not found page if slug doesn't exist using React Router Dom?
- How to Handle Redirecting to the Same Route (with Query Params) Using React Router v4
- How to track page views in react using reach router and google analytics?
- How to do non-existent routes redirect to homepage in react router dom?
- How can i redirect to a component in react redux after returning promise (axios) . I am using react router 4
- How to create list and detail view using React Router DOM?
- React router - click on card and redirect to a new page with content of that card (card details) using useParams and reacthooks
- Trying to migrate from React router v3 to v5 , Unable to figure out how to pass 'props.children' and redirect after authentication
- How to redirect user to url "/home" after some request is complete using react and typescript?
- how to redirect using react router
- How to click a button and navigate to a new route with URL params using React Router 4
- Im using React Router and I want one of my route links with path="/" to be the home page on reload.. How can you do that?
- How can I pass props from one component to another using Link and router in react
- I want to popup each item to view and edit . How can I do this using modal with router in react js?
- How to redirect to another page using navlink react router
- How to redirect a user based on their referrer using React Router
- When and how to redirect with Apollo Client and React Router
- How to Use URL Parameters and Query Strings With React Router
- Can't figure out how to pass props to components when using React Router v5 and Redux
- How to redirect to from /login to elsewhere if user is signed-in using React router
- How to import and export components using React + ES6 + webpack?
- How to render react components by using map and join?
- How to store Configuration file and read it using React
- How to redirect in React Router v6?
- How to query by text string which contains html tags using React Testing Library?
- You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react
- How to mock history.push with the new React Router Hooks using Jest
More Query from same tag
- Child component doesn't rerender but parent component does rerender. How to make child component rerender?
- I want to select value from react select
- apollo-client used to make multiple requests to make a real-time search
- How to convert all email addresses to links and put them into a React component?
- API calls in componentDidUpdate and componentWillReceiveProps
- jest enzyme test method in componentDidMount fails but console shows that it is working
- CSRF Failed: Origin checking failed - http://localhost:8000/ does not match any trusted origins
- react/ redux app : actions not dispatching to store
- Loading state not effective in the React application (MobX)
- How do I get documents from Firebase / Firestore ordered by property value
- React server-side and client side rendering not seamless
- Passing props to another component in React.js
- Format for sending location data in body
- I want to change the color of button in react using material ui
- prevent values in Fields of redux-from on unsuccessfull api response
- Unable to parse data from react firebase object
- react-countdown resets when rendered in ReactJs
- Render a table in the rows of another table in react
- Array.prototype.map() expects a return value from arrow function array-callback-return
- Icon should have `type` prop or `component` prop or `children`?
- Import Local json data into React State
- reactjs get the children count of an element
- Node/Express Cannot POST error (React frontend)
- Why does my Redux props object return undefined?
- Align buttons at different nesting levels
- How to use react hooks useEffect/useReducer + useContext to change context's value in ts gracefully?
- How can i add data in Realtime and display in my React app
- How to set Material-UI breakpoint for small, medium, and large screen with `useMediaQuery`
- React Component and constructor bind not working
- Difference in typing when passing spread props vs html-style attributes