question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

any way to turn off `:s` style emojis?

See original GitHub issue
import { toArray } from 'react-emoji-render';

// "Names must be lowercase, and can't contain spaces, periods, or most punctuation."
// -super helpful slack emoji name validation message
const SLACK_EMOJI_PATTERN = /:([\w+_-]+):\s?/gi;

export const renderEmojis = (value: string) => {
  const emojisArray = toArray(value)

  console.log(emojisArray);

  // toArray outputs React elements for emojis and strings for other
  const newValue = emojisArray.reduce<string>(
    (previous: string, current: string | React.ReactElement) => {
      if (typeof current === 'string') {
        // omit un-rendered emojis
        return previous + current.replace(SLACK_EMOJI_PATTERN, '');
      }
      return previous + (current.props.children as string);
    },
    ''
  );

  return newValue;
};

console.log(renderEmojis(
  ":stacked=\"isStackedGraph\"\r\n"
))

===>

 😒tacked="isStackedGraph"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
nickvelikicommented, Jul 18, 2021

As written above, you could exclude certain string patterns from the toArray call as a solution. For example, if you want to ignore all “😒”, you could write something like .split(“😒”).map(toArray).join(“😒”). Note that Slack-like emojis starting with 😒 would also be skipped with this piece of code.

split(/(?<= )😒(?= )/) will only exclude 😒 if it is standing alone…

1reaction
enzofereycommented, Jul 18, 2021

Hi @andycmaj ! Sorry for the late answer, did you find any solution to your issue ?

We do not support disabling these emojis, but maybe you could exclude the part of the string that you don’t want to be included in the matching based on your use case ?

Like

`:${renderEmojis("...")}`

or whatever your need is (I don’t see any other emojis on the string you provided).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tip: Ban Emojis From Android and iOS - Thurrott.com
Apple simply lets you remove the emoji key, which is the approach I like the best: Navigate to Settings > General > Keyboard...
Read more >
Suggest Emoji Setting on Samsung Galaxy S21 - YouTube
Check out more: https://www.hardreset.info/devices/samsung/samsung-galaxy-s21/Samsung Galaxy S21 has Emoji Suggest setting turned on ...
Read more >
How to Turn Off Auto Emojis on Discord Mobile - iOS & Android
How to turn off auto emojis in Discord mobile? In this tutorial, I show you how to disable Discord auto emojis. Turning off...
Read more >
How to Enable/Disable Keyboard Suggest Emojis - YouTube
Learn how you can enable or disable keyboard suggest emojis on the Samsung Galaxy S22 / S22+ / S22 Ultra. Gears I use:Velbon...
Read more >
How to Change Android Emojis - YouTube
Want IOS Emojis on your Android device? Here's how you can change them. Emoji Search: https://goo.gl/AKJoJVEmoji Switch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found