Commit 8a644ef
committed
[add] load images with http headers
- extend ImageLoader.load params
- Removed the old `image.decode` change as it's covered by the minimal browser versions supported here
- add examples for Images with headers
- Image - remove requestRef - no longer needed
- rename `ImageLoader.abort` to `.release`
The method is mostly used as cleanup
(e.g. useEffect cleanup, or releasing resources when component unmounts)
- Image - extract `useSource` hook
Move the image loading effect here
Changed the original logic slightly for less nesting
Changed to cover cases where passing the same headers object was starting new loads, as it was treated as a different value due to referential equality
- Image - add tests covering added/changed functionality around source
- Image - handle cases where the source object only changes by reference
When the source object changed by reference, but stays structurally the same, we should do nothing and not trigger the loading effect again
- Image - extract ImageLoadingProps
Update types to match RN and actual code - we don't call `onLoadStart` and `onLoadEnd` with any arguments
- ImageLoader extract types.js
- Image - resolve `onLoad` with `source`
Use the same `nativeEvent` structure as in RN for the onLoad event
- Rework Image loading and source management logic
Since introducing the change to support headers changes to the original
changes are needed:
- support loading a default source with headers
- handle source object changes
- update uri resolving logic to handle blob URLs create by `URL.createObjectURL`
- move the URI/source resolving logic to the `ImageLoader`
BREAKING CHANGE
`onLoad` was previously called with `nativeEvent` that was the browser Event object
from the image.onload handler
Since we can't spread or mutate the Event object to add `source` we have to
either add it under a new key or remove it
The browser Event does not expose very useful information, (no target, or size info),
so it seems best to replace `nativeEvent` with the same structure used in `react-native`1 parent fa47f80 commit 8a644ef
File tree
7 files changed
+461
-165
lines changed- packages
- react-native-web-examples/pages/image
- react-native-web/src
- exports/Image
- __tests__
- __snapshots__
- modules/ImageLoader
7 files changed
+461
-165
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
18 | 30 | | |
19 | 31 | | |
20 | 32 | | |
| |||
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
34 | | - | |
35 | | - | |
| 46 | + | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| |||
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
117 | 140 | | |
118 | 141 | | |
119 | 142 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
Lines changed: 138 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | 132 | | |
134 | 133 | | |
135 | 134 | | |
| |||
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
177 | 208 | | |
178 | 209 | | |
179 | 210 | | |
| |||
225 | 256 | | |
226 | 257 | | |
227 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
228 | 297 | | |
229 | 298 | | |
230 | 299 | | |
| |||
244 | 313 | | |
245 | 314 | | |
246 | 315 | | |
| 316 | + | |
247 | 317 | | |
248 | | - | |
| 318 | + | |
| 319 | + | |
249 | 320 | | |
250 | 321 | | |
251 | 322 | | |
| |||
261 | 332 | | |
262 | 333 | | |
263 | 334 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | 335 | | |
270 | 336 | | |
271 | 337 | | |
| |||
308 | 374 | | |
309 | 375 | | |
310 | 376 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
317 | 384 | | |
318 | 385 | | |
319 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
320 | 395 | | |
| 396 | + | |
| 397 | + | |
321 | 398 | | |
322 | | - | |
| 399 | + | |
| 400 | + | |
323 | 401 | | |
| 402 | + | |
324 | 403 | | |
325 | 404 | | |
326 | 405 | | |
| |||
346 | 425 | | |
347 | 426 | | |
348 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
349 | 468 | | |
350 | 469 | | |
351 | 470 | | |
| |||
0 commit comments