goshacmd / react-native-simple-emoji-picker

A simple emoji picker component for React Native
42 stars 14 forks source link

error String.fromCodePoint #1

Open joaomarcoscmaciel opened 7 years ago

joaomarcoscmaciel commented 7 years ago

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!

goshacmd commented 7 years ago

Which React Native version are you using?

guilhermesad commented 7 years ago

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

nikolay-radkov commented 7 years ago

@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

MSSPL-PiyaleeMaiti commented 7 years ago

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

mieszko4 commented 7 years ago

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
wayne1203 commented 6 years ago

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

mieszko4 commented 6 years ago

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

mihailShumilov commented 6 years ago

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

mieszko4 commented 6 years ago

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 commented 6 years ago

Not sure what plans @goshakkk has for that package.

mihailShumilov commented 6 years ago

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

profiVideos commented 6 years ago

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 ...

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