Skip to content

Commit dde8398

Browse files
committed
Update the readme code examples.
1 parent 03dca0e commit dde8398

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# apollo-upload-client changelog
22

3+
## Next
4+
5+
### Patch
6+
7+
- Updated the readme code examples.
8+
39
## 19.0.0
410

511
### Major

readme.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function UploadFileList() {
5656
multiple
5757
required
5858
onChange={({ target: { validity, files } }) => {
59-
if (validity.valid)
59+
if (validity.valid && files?.[0])
6060
mutate({
6161
variables: {
6262
files,
@@ -99,16 +99,11 @@ function UploadFile() {
9999
<input
100100
type="file"
101101
required
102-
onChange={({
103-
target: {
104-
validity,
105-
files: [file],
106-
},
107-
}) => {
108-
if (validity.valid)
102+
onChange={({ target: { validity, files } }) => {
103+
if (validity.valid && files?.[0])
109104
mutate({
110105
variables: {
111-
file,
106+
file: files[0],
112107
},
113108
});
114109
}}
@@ -145,20 +140,20 @@ function UploadBlob() {
145140
>(mutation);
146141

147142
return (
148-
<input
149-
type="text"
150-
required
151-
onChange={({ target: { validity, value } }) => {
152-
if (validity.valid)
153-
mutate({
154-
variables: {
155-
file: new Blob([value], {
156-
type: "text/plain",
157-
}),
158-
},
159-
});
143+
<button
144+
type="button"
145+
onClick={() => {
146+
mutate({
147+
variables: {
148+
file: new Blob(["Content here."], {
149+
type: "text/plain",
150+
}),
151+
},
152+
});
160153
}}
161-
/>
154+
>
155+
Upload
156+
</button>
162157
);
163158
}
164159

0 commit comments

Comments
 (0)