Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
How can i replace string in react

im using emoji api and i get emoji unicode's like this U+1F425 to be able to show emoji's in jsx. i have to replace U+1F425 to \u{1F425} . basically i just need to get 1F425 from the api.

Emoji.jsx

import React, { useEffect, useState } from "react";
import Sidebar from "../../Sidebar/Sidebar";
import "./Emoji.css";

const Emoji = ({ isAuth, setIsAuth }) => {
  const [type, setType] = useState([]);
  const getEmoji = () => {
    fetch("https://emojihub.herokuapp.com/api/all/group_animal_bird")
      .then((resp) => resp.json())
      .then((dat) => (console.log(dat), setType(dat)));
  };

  useEffect(() => {
    getEmoji();
    console.log(type);
  }, []);
  return (
    <>
              {type.map((emo) => (
                <>
                  <h6>{emo.name}</h6>
                  <span>{emo.unicode}</span> // This Not
                  <span>{"\u{1F985}"}</span> //This works
                </>
              ))}
    
    </>
  );
};

export default Emoji;

thanks for your help!

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Emojis are nothing but characters. You have to convert that code to hex and then convert that hex code to string.

 const res = '1F425';
// Convert your string to hex code
 const resHex = +`0x${res}`;
// Convert Hex to string
 String.fromCodePoint(resHex); // You can render this directly
about 4 years ago · Juan Pablo Isaza Report

0

<span dangerouslySetInnerHTML={{ __html: emo.htmlCode[0] }}></span>
about 4 years ago · Juan Pablo Isaza Report

0

Slicing the emoji code got from API should work...

import React, { useEffect, useState } from "react";
import Sidebar from "../../Sidebar/Sidebar";
import "./Emoji.css";

const Emoji = ({ isAuth, setIsAuth }) => {
  const [type, setType] = useState([]);
  const getEmoji = () => {
    fetch("https://emojihub.herokuapp.com/api/all/group_animal_bird")
      .then((resp) => resp.json())
      .then((dat) => (console.log(dat), setType(dat)));
  };

  useEffect(() => {
    getEmoji();
    console.log(type);
  }, []);
  return (
    <>
              {type.map((emo) => (
                <>
                  <h6>{emo.name}</h6>
                  <span>{"\u{" + emo.unicode.slice(2) + "}"}</span> //This should work now.
                </>
              ))}
    
    </>
  );
};

export default Emoji;

...you may try this out.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!