@@ -96,28 +96,38 @@ submit([
96
96
]);
97
97
```
98
98
99
- The default behavior if you submit a JSON object is to encode the data into ` FormData ` :
99
+ The default behavior if you submit a JSON object for a POST submission is to encode the data into ` FormData ` :
100
100
101
101
``` tsx
102
- submit ({ key: " value" });
102
+ submit ({ key: " value" }, { method: " post " } );
103
103
// will serialize into request.formData() in your action
104
+ // and will show up on useNavigation().formData during the navigation
104
105
```
105
106
106
107
Or you can opt-into JSON encoding:
107
108
108
109
``` tsx
109
- submit ({ key: " value" }, { encType: " application/json" });
110
+ submit (
111
+ { key: " value" },
112
+ { method: " post" , encType: " application/json" }
113
+ );
110
114
// will serialize into request.json() in your action
115
+ // and will show up on useNavigation().json during the navigation
111
116
112
- submit (' {"key":"value"}' , { encType: " application/json" });
117
+ submit (' {"key":"value"}' , {
118
+ method: " post" ,
119
+ encType: " application/json" ,
120
+ });
113
121
// will encode into request.json() in your action
122
+ // and will show up on useNavigation().json during the navigation
114
123
```
115
124
116
125
Or plain text:
117
126
118
127
``` tsx
119
- submit (" value" , { encType: " text/plain" });
128
+ submit (" value" , { method: " post " , encType: " text/plain" });
120
129
// will serialize into request.text() in your action
130
+ // and will show up on useNavigation().text during the navigation
121
131
```
122
132
123
133
## Submit options
@@ -126,8 +136,8 @@ The second argument is a set of options that map (mostly) directly to form submi
126
136
127
137
``` tsx
128
138
submit (null , {
129
- action: " /logout" ,
130
139
method: " post" ,
140
+ action: " /logout" ,
131
141
});
132
142
133
143
// same as
0 commit comments