You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to use `throw` with any of the `redirectWith...` utilities you need to `await` the function call. This is because `redirectWith...` utilities have to generate a cookie and set it on the headers and if that is not awaited the headers won't be set properly and the redirect won't work.
258
254
259
-
260
-
261
255
### redirectWithToast
262
256
263
257
General function that allows you to redirect to a new route and show a toast message.
@@ -266,9 +260,12 @@ General function that allows you to redirect to a new route and show a toast mes
266
260
import { redirectWithToast } from"remix-toast";
267
261
268
262
exportconst action = () => {
269
-
returnredirectWithToast("/login", { message: "You need to login to access this page", description: "description of toast", type: "error" });
270
-
}
271
-
263
+
returnredirectWithToast("/login", {
264
+
message: "You need to login to access this page",
265
+
description: "description of toast",
266
+
type: "error",
267
+
});
268
+
};
272
269
```
273
270
274
271
### redirectWithSuccess
@@ -279,11 +276,10 @@ Redirects to a new route and shows a success toast message.
279
276
import { redirectWithSuccess } from"remix-toast";
280
277
281
278
exportconst action = () => {
282
-
returnredirectWithSuccess("/login", "You are logged in!");
279
+
returnredirectWithSuccess("/login", "You are logged in!");
283
280
//or with description and message (works for all the other utilities as well)
284
281
returnredirectWithSuccess("/login", { message: "You are logged in!", description: "description of toast" });
285
-
}
286
-
282
+
};
287
283
```
288
284
289
285
### redirectWithError
@@ -295,8 +291,7 @@ import { redirectWithError } from "remix-toast";
295
291
296
292
exportconst action = () => {
297
293
returnredirectWithError("/login", "You need to login to access this page");
298
-
}
299
-
294
+
};
300
295
```
301
296
302
297
### redirectWithInfo
@@ -332,8 +327,11 @@ import { dataWithSuccess } from "remix-toast";
0 commit comments