Skip to content

Instantly share code, notes, and snippets.

@gaearon
Last active June 30, 2018 15:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaearon/56e4e77d7df109ef0c7b727a3d403acf to your computer and use it in GitHub Desktop.
Save gaearon/56e4e77d7df109ef0c7b727a3d403acf to your computer and use it in GitHub Desktop.

JavaScript Environment Requirements

React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (eg <IE11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

A polyfilled environment for React 16 using core-js to support older browsers might look like:

import 'core-js/es6/map';
import 'core-js/es6/set';

import React from 'react';
import ReactDOM from 'react-dom';

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

React also depends on requestAnimationFrame (even in test environments). A simple shim for testing environments would be:

global.requestAnimationFrame = function(callback) {
  setTimeout(callback, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment