react-native-simple-emoji-picker
react-native-simple-emoji-picker copied to clipboard
error String.fromCodePoint
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!
Which React Native version are you using?
I'm getting the same thing:

I'm using React Native version 0.41.2
and node version v6.9.1
@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
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..
Try the following:
-
npm install babel-polyfill --save-dev
- In your
index.android.js
andindex.ios.js
addimport "babel-polyfill";
at the begining
@mieszko4 Thanks for your solution. After that I got another error now....
I'm using RN 0.49
I haven't used 0.49 yet. Try with 0.48.1 - if it works, see what breaking changes there are in 0.49
I have the same issue right now... all works as expected when you enable js debug If you disable js debug - you got error
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
Not sure what plans @goshakkk has for that package.
I also fork it and already added fix for that https://github.com/mihailShumilov/react-native-simple-emoji-picker
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 ...
- npm install babel-polyfill --save-dev
- Add below code in data.js file require('string.fromcodepoint');