Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: Can't find variable: Set (react.js Only in safari this error is coming)

ReferenceError: Can't find variable: Set (react.js Only in safari this error is coming) on all other browsers its working perfect but in safari throwing this error showing error in main.js which was build by react when i run this command (npm run build)

like image 626
Gursimran Bedi Avatar asked Feb 13 '18 07:02

Gursimran Bedi


2 Answers

You should consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

Run npm install core-js or yarn add core-js and import your specific required features, like so:

  import 'core-js/es6/map';
  import 'core-js/es6/set';
  import 'core-js/fn/array/find';
  import 'core-js/fn/array/includes';
  import 'core-js/fn/number/is-nan';

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

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

More info: https://reactjs.org/docs/javascript-environment-requirements.html

like image 104
Albert Olivé Avatar answered Oct 22 '22 08:10

Albert Olivé


You can add import "core-js/fn/set"; into your pollyfill.js file, in order to support old browsers.

Note: Please install "core-js" package incase you don't have.

like image 42
Faiz A. Farooqui Avatar answered Oct 22 '22 07:10

Faiz A. Farooqui