What are the rules of a Form for a POST action to /any-route makes the action redirect to /any-route - or not ? #1952
-
I've hard time knowing when a form would redirect me to the action route or not. For instance, in my social networking app, I have a For the like/unlike button, here it is: <Form method="post">
<input type="hidden" name="postId" value={_id} />
<button
type="submit"
name="_post_action"
formAction="/post-actions"
value={isLiked ? "unlike" : "like"}
>
<ThumbUp fill={showAsLiked ? "currentColor" : "none"} />
</button>
</Form> Just right now when I implement it, when I click on a like it redirects to I switched to But I'm a bit lost in all of this subject : when will Remix redirect to an action route ? When will it not ? What are the conditions ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Remix provides both navigating and non-navigating versions for POST requests so you can choose:
I made a cheatsheet for Remix requests: https://gist.github.com/na2hiro/136c67bbe01526eb71911d37990ed445 |
Beta Was this translation helpful? Give feedback.
Remix provides both navigating and non-navigating versions for POST requests so you can choose:
Form
,submit()
fetcher.Form
,fetcher.submit()
I made a cheatsheet for Remix requests: https://gist.github.com/na2hiro/136c67bbe01526eb71911d37990ed445