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
Copy file name to clipboardExpand all lines: docs/hooks/use-navigation.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ function SomeComponent() {
27
27
navigation.text;
28
28
navigation.formAction;
29
29
navigation.formMethod;
30
+
navigation.formEncType;
30
31
}
31
32
```
32
33
@@ -108,6 +109,45 @@ This tells you what the next [location][location] is going to be.
108
109
109
110
Note that this link will not appear "pending" if a form is being submitted to the URL the link points to, because we only do this for "loading" states. The form will contain the pending UI for when the state is "submitting", once the action is complete, then the link will go pending.
110
111
112
+
## `navigation.formAction`
113
+
114
+
Any POST, PUT, PATCH, or DELETE navigation that started from a `<Form>` or `useSubmit` will have form's submission action route's path value available in `navigation.formAction`.
115
+
116
+
In the case of a GET form submission, `navigation.formAction` will be empty
117
+
118
+
If you submitted the form at `example.com/id`, then `navigation.formAction` would be "/id"
119
+
120
+
## `navigation.formMethod`
121
+
122
+
Any POST, PUT, PATCH, or DELETE navigation that started from a `<Form>` or `useSubmit` will have form's submission method value available in `navigation.formMethod`.
123
+
124
+
In the case of a GET form submission, `navigation.formMethod` will be empty
125
+
126
+
Here is an example. Please note that `navigation.formMethod` is in lowercase
127
+
128
+
```tsx
129
+
function SubmitButton() {
130
+
const navigation =useNavigation();
131
+
if (navigation.formMethod){
132
+
console.log(navigation.formMethod) // post
133
+
}
134
+
135
+
return (
136
+
<Formmethod="POST">
137
+
<button>Submit</button>
138
+
</Form>
139
+
);
140
+
}
141
+
```
142
+
143
+
## `navigation.formEncType`
144
+
145
+
Any POST, PUT, PATCH, or DELETE navigation that started from a `<Form>` or `useSubmit` will have form's submission method value available in `navigation.formEncType`.
146
+
147
+
This property can be one of the four values: "text/plain," "application/json," "multipart/form-data," or "application/x-www-form-urlencoded."
148
+
149
+
In the case of a GET form submission, `navigation.formEncType` will be empty
0 commit comments