From d213619e92a0b606e7bce4f418040049639cc806 Mon Sep 17 00:00:00 2001 From: Siarhei Bobryk Date: Sun, 3 Oct 2021 12:45:14 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=84=20Note=20about=20Promises=20for=20?= =?UTF-8?q?`React.lazy`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the note section of [`React.lazy`](https://reactjs.org/docs/react-api.html#reactlazy) > Using `React.lazy` with dynamic import requires Promises to be available in the JS environment. This requires a polyfill on IE11 and below. From my perspective, it is worth noting here about polyfilling Promises as well as import it in the example. --- content/docs/reference-javascript-environment-requirements.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/docs/reference-javascript-environment-requirements.md b/content/docs/reference-javascript-environment-requirements.md index f26f2f7a43f..146afb2960a 100644 --- a/content/docs/reference-javascript-environment-requirements.md +++ b/content/docs/reference-javascript-environment-requirements.md @@ -6,13 +6,14 @@ category: Reference permalink: docs/javascript-environment-requirements.html --- -React 16 depends on the collection types [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11) or which have non-compliant implementations (e.g. IE 11), consider including a global polyfill in your bundled application, such as [core-js](https://github.com/zloirock/core-js). +React 16 depends on the collection types [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). Also using [React.lazy](/docs/react-api.html#reactlazy) with dynamic import requires [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to be available in the JS environment. If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11) or which have non-compliant implementations (e.g. IE 11), consider including a global polyfill in your bundled application, such as [core-js](https://github.com/zloirock/core-js). A polyfilled environment for React 16 using core-js to support older browsers might look like: ```js import 'core-js/es/map'; import 'core-js/es/set'; +import 'core-js/es/promise'; import React from 'react'; import ReactDOM from 'react-dom';