What I want is a really simple React component that returns a random emoji out of a list of allowed ones, for readability I've just created a string with all the allowed emoji I want it to choose from and then returning a random one, but what I'm getting is the �-symbol (unicode replacement char).
This is my code:
import React from 'react';
export default () => {
const allowedEmoji = '✌️';
return (
<span role="img" aria-label="hello">
{allowedEmoji[Math.floor(Math.random() * allowedEmoji.length)]}
</span>
);
};
I'm guessing this has to do with encoding and emojis in a string taking up more than one index? Can someone please clarify this?