Skip to content

Commit f0518cc

Browse files
docs: add fetch polyfill disclaimer to testing section (#9460)
1 parent d9d233c commit f0518cc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

contributors.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- alexlbr
77
- AmRo045
88
- andreiduca
9+
- arnassavickas
910
- aroyan
1011
- avipatel97
1112
- awreese

docs/routers/picking-a-router.md

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ If you're not interested in the data APIs, you can continue to use [`<BrowserRou
6666

6767
Testing components that use React Router APIs is easiest with [`createMemoryRouter`][creatememoryrouter] or [`<MemoryRouter>`][memoryrouter] instead of the routers you use in your app that require DOM history APIs.
6868

69+
Some of the React Router APIs internally use `fetch`, which is only supported starting from Node.js v18. If your project uses v17 or lower, you should add a `fetch` polyfill manually. One way to do that, is to install [`whatwg-fetch`](https://www.npmjs.com/package/whatwg-fetch) and add it to your `jest.config.js` file like so:
70+
```js
71+
module.exports = {
72+
setupFiles: ['whatwg-fetch'],
73+
// ...rest of the config
74+
}
75+
```
76+
6977
## React Native
7078

7179
You will use [`<NativeRouter>`][nativerouter] from React Native projects.

0 commit comments

Comments
 (0)