react-native-simple-emoji-picker icon indicating copy to clipboard operation
react-native-simple-emoji-picker copied to clipboard

error String.fromCodePoint

Open joaomarcoscmaciel opened this issue 7 years ago • 13 comments

Hello goshakkk,

I'm receiving an error of: undefined is not an object (evaluating 'String.fromCodePoint.apply') They direct to the line 4 of data.js: const charFromCode = utf16 => String.fromCodePoint(...utf16.split('-').map(u => '0x' + u));

Can you help me? Thanks in advance!

joaomarcoscmaciel avatar Mar 25 '17 02:03 joaomarcoscmaciel

Which React Native version are you using?

goshacmd avatar Apr 18 '17 18:04 goshacmd

I'm getting the same thing:

screen shot 2017-05-01 at 9 08 03 pm

I'm using React Native version 0.41.2 and node version v6.9.1

guilhermesad avatar May 02 '17 00:05 guilhermesad

@joaomarcoscmaciel @guilhermesad Try to polyfill String.fromCodePoint in your starting file with this:

/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */ if (!String.fromCodePoint) { (function() { var defineProperty = (function() { // IE 8 only supports Object.defineProperty on DOM elements try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || // NaN, +Infinity, or -Infinity codePoint < 0 || // not a valid Unicode code point codePoint > 0x10FFFF || // not a valid Unicode code point floor(codePoint) != codePoint // not an integer ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { // BMP code point codeUnits.push(codePoint); } else { // Astral code point; split in surrogate halves // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }

Source String.fromCodePoin doc

nikolay-radkov avatar May 10 '17 20:05 nikolay-radkov

I am using react native 0.40, also getting same issue. After install this plugin and run the project then showing the issue, but when on the debugger then the error is gone. Please suggest any solution ASAP @nikolay-radkov . Below the screenshot.. screenshot_1494930689

MSSPL-PiyaleeMaiti avatar May 16 '17 10:05 MSSPL-PiyaleeMaiti

Try the following:

  1. npm install babel-polyfill --save-dev
  2. In your index.android.js and index.ios.js add import "babel-polyfill"; at the begining

mieszko4 avatar Sep 17 '17 21:09 mieszko4

@mieszko4 Thanks for your solution. After that I got another error now.... I'm using RN 0.49 screenshot_1509078742

wayne1203 avatar Oct 27 '17 04:10 wayne1203

I haven't used 0.49 yet. Try with 0.48.1 - if it works, see what breaking changes there are in 0.49

mieszko4 avatar Oct 27 '17 07:10 mieszko4

I have the same issue right now... all works as expected when you enable js debug If you disable js debug - you got error

mihailShumilov avatar Jan 03 '18 12:01 mihailShumilov

This looks like the problem with new react in which you have to use import PropTypes from "prop-types"; (https://github.com/goshakkk/react-native-simple-emoji-picker/blob/master/index.js#L1)

Unfortunately this package hasn't been updated for over 1 year. I had to fork it to fix some stuff - https://github.com/IvySpace-Dev/react-native-emoji-picker

mieszko4 avatar Jan 03 '18 15:01 mieszko4

Not sure what plans @goshakkk has for that package.

mieszko4 avatar Jan 03 '18 15:01 mieszko4

I also fork it and already added fix for that https://github.com/mihailShumilov/react-native-simple-emoji-picker

mihailShumilov avatar Jan 03 '18 15:01 mihailShumilov

I'm still learning Git and stuff. How do I install the fixes you made? I used yarn add react-native-simple-emoji-picker and it installed the broken version. As I said, I'm new ...

profiVideos avatar Jan 04 '18 21:01 profiVideos

  1. npm install babel-polyfill --save-dev
  2. Add below code in data.js file require('string.fromcodepoint');

shahchaitanya avatar Feb 09 '18 14:02 shahchaitanya