uppy/packages/@uppy/react
Prakash 804363e86e
@uppy: upgrade vitest to v4 (#6309)
This PR Bumps the `vitest` across the monorepo:

AI Disclaimer : **AI Used**

  | Package | From | To |
  |---|---|---|
  | `vitest` | `^3.2.4` | `^4.1.6` |
  | `@vitest/browser` | `^3.2.4` | `^4.1.6` |
  | `@vitest/browser-playwright` | _(new)_ | `^4.1.6` |
| `vitest-browser-react/-vue/-svelte` | `^1.0.0` | `^2.x` (required by
vitest 4) |

Covers **21 `package.json` files** for `vitest`/`@vitest/browser` + the
**7 browser-mode packages** that need the new
  `@vitest/browser-playwright` provider.

  ### Code changes required by vitest 4

Per the [official migration
guide](https://vitest.dev/guide/migration.html#vitest-4):

- **Browser provider rework** — `provider: 'playwright'` (string) →
`playwright()` factory. Migrated 7 `vitest.config.ts` files
(`@uppy/{url,dashboard,golden-retriever,xhr-upload}` +
`examples/{react,vue,sveltekit}`).
- **Deprecated `@vitest/browser/context` imports** → `vitest/browser`.
Migrated 8 test files.
- **`vi.fn(arrow)` no longer constructible with `new`.** Vitest 4 made
`vi.fn()` callable as a constructor but arrow-fn
implementations throw. Switched `@uppy/transloadit`'s `EventSource` mock
to a regular function:
    ```js
global.EventSource = vi.fn(function MockEventSource() { return { /* ...
*/ } })
    ```
- **`Mock<T>` generic shape changed.** `ReturnType<typeof vi.fn>` now
resolves to `Mock<Procedure | Constructable>` (not directly
callable). Updated `@uppy/core`'s two `acquirerPlugin*.ts` mock helpers
to use an explicit `Mock<(...args: any[]) => any>`.
- **`vitest-browser-*` v2 made `render()` async.** Added `await
render(...)` in the 3 example test files.
- **`@types/node` needed in TS program for 4 packages** whose test files
import `node:assert`/`node:fs`/`node:path`
(`@uppy/{core,compressor,aws-s3,store-default}`). Vitest 3 transitively
pulled in `@types/node`; vitest 4 does not. Added the
  devDep + `types: ["preact", "node"]` to those four tsconfigs.
- **`@uppy/utils` `AbortController.test.ts`** — vitest 4's jsdom env
puts jsdom's `Event` on `globalThis`, while Node's
`AbortController` fires Node-realm `Event`s, breaking cross-realm
`instanceof`. Added `// @vitest-environment node` to that one
  file (DOM-agnostic test, no behavior change).
  
  ### Notes

- This PR is built on top of `uppy-upgrade-deps-v2` (the no-code-changes
dep bumps PR) and inherits those. If merging out of order,
   rebase onto `main` after `uppy-upgrade-deps-v2` lands.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-26 21:54:07 +05:30
..
src Add useImageEditor (#6122) 2026-01-29 11:13:12 +01:00
.npmignore @uppy/react: refactor to TS (#5012) 2024-03-27 11:03:34 +01:00
CHANGELOG.md [ci] release (#6166) 2026-02-03 11:08:41 +01:00
LICENSE Move React components to @uppy/react package. 2018-06-18 10:14:08 +02:00
package.json @uppy: upgrade vitest to v4 (#6309) 2026-05-26 21:54:07 +05:30
README.md Fix links (#5492) 2024-10-29 13:54:00 +01:00
tsconfig.build.json add back framework wrappers for @uppy/status-bar (#5948) 2025-09-17 10:40:57 +02:00
tsconfig.json add back framework wrappers for @uppy/status-bar (#5948) 2025-09-17 10:40:57 +02:00
turbo.json Add useImageEditor (#6122) 2026-01-29 11:13:12 +01:00

@uppy/react

Uppy logo: a smiling puppy above a pink upwards arrow

npm version CI status for Uppy tests CI status for Companion tests CI status for browser tests

React component wrappers around Uppys officially maintained UI plugins.

Uppy is being developed by the folks at Transloadit, a versatile file encoding service.

Example

/** @jsx React */
import React from 'react'
import Uppy from '@uppy/core'
import { DashboardModal } from '@uppy/react'

const uppy = new Uppy()

class Example extends React.Component {
  state = { open: false }

  render() {
    const { open } = this.state
    return (
      <DashboardModal
        uppy={uppy}
        open={open}
        onRequestClose={this.handleClose}
      />
    )
  }
  // ..snip..
}

Installation

$ npm install @uppy/react

Alternatively, you can also use this plugin in a pre-built bundle from Transloadits CDN: Smart CDN. In that case Uppy will attach itself to the global window.Uppy object. See the main Uppy documentation for instructions.

Documentation

Documentation for this plugin can be found on the Uppy website.

License

The MIT License.