React-sortable-hoc: [Polyfill needed] Array.from is unsupported in Safari 8 and Internet Explorer

Created on 6 Feb 2017  路  10Comments  路  Source: clauderic/react-sortable-hoc

Its an awesome library, however, it doesn't work with Safari (I've tested Chrome and Firefox successfully).

This is the error that I get when I try to sort the items:
[Error] TypeError: undefined is not a function (evaluating 'Array.from(arr)')

and this is the line that is apparently causing the problems:
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

Any suggestions on how to solve this?

Most helpful comment

FYI
The demo at http://clauderic.github.io/react-sortable-hoc
doesn't work in IE 11

I've added to this issue as I think it's related?

All 10 comments

It seems that this function Array.from("some array") is not supported in my current Safari version (8).

According to this page Safari 8 is lacking many functionalities, Safari 9 is a bit better and Safari 10 (newest) has everything supported.

Hey @stenbln, thanks for reporting this. This isn't something in the code explicitly, so I'll take a look and and try to make sure webpack doesn't fall back on Array.from behind the scenes, because I'd rather not have to include a polyfill for this since there are other cross-browser ways to achieve the same thing.

In the meantime, if you're itching to try out react-sortable-hoc, you can add a polyfill for Array.from in your code before react-sortable-hoc is initialized.

Great. I've added the code that you linked and now it works even in Safari 8.

Maybe you find this information helpful. I've found out that this [].slice.call("some array") does the same thing as Array.from("some array") and it is supported also in Safari.

Thanks for the library. I really like it :1st_place_medal:

FYI
The demo at http://clauderic.github.io/react-sortable-hoc
doesn't work in IE 11

I've added to this issue as I think it's related?

I ran into a similar issue that adding a Polyfill for Array.from fixed. Isn't there a way to just not use Array.from?

@mccambridge can you please help me in adding Array.from Plyfill. I tried this (https://www.npmjs.com/package/array-from), this is not working in IE. Still getting the same error in console.

object doesn't support property or method 'from'

Please let me know how you used Polyfill

@Shardendu-kantha I am not sure if you were able to get it working. If not, try using https://www.npmjs.com/package/array.from package. And in your code you would have to do the following:
require('array.from').shim();

Your code can then use Array.from.

@clauderic any chance, you were able to rewrite the library without using Array.from?

@arvind1234 hey, sorry for being little late. I got it resolved by the same suggested by you.

Solution

I am facing the same issue and @Shardendu-kantha but array-from doesn't seem to work. It seems like react-sortable-hoc will have to add polyfill for it in their library to resolve this.

In response to comment from @DeeLindesay, I found the demo working when I tested it today in IE11:

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sir4ur0n picture Sir4ur0n  路  3Comments

ianmstew picture ianmstew  路  3Comments

ccharliemagne picture ccharliemagne  路  3Comments

sammiwei911 picture sammiwei911  路  3Comments

botoxparty picture botoxparty  路  3Comments