-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【Bug Report】"Emoji" component is not working for Next.js #607
Comments
see: #575 (comment) |
@austinbuckler So.., I want to know, how to display "Emoji" component, by use of dynamic import and ref callback function. |
Any updates on this? |
I can take a look sometime tonight/this week. I don't have a use-case for the |
I am using Picker in Nextjs . This method works fine .
import React, { useEffect, useRef } from "react";
import data from "@emoji-mart/data";
import { Picker } from "emoji-mart";
const EmojiPicker = (props) => {
const ref = useRef(null);
useEffect(() => {
new Picker({ ...props, data, ref });
}, []);
return <div ref={ref} />;
};
export default EmojiPicker; The file where you want to use EmojiPicker component .
import React from "react"
import dynamic from "next/dynamic"
const EmojiPicker = dynamic(() => import("./EmojiPicker"), {
ssr: false,
});
const Page = () => {
return <EmojiPicker />
}
export default Page |
@saurabhmehta1601 |
Yeah you can pass function
const EmojiPicker = (props) => {
const ref = useRef(null)
useEffect(() => {
new Picker({
...props,
data,
onEmojiSelect: (emoji) => {
// You can grab selected emoji here and do what you want with it
console.log("selected emoji is " , emoji.native)
},
});
}, []);
return <div ref={ref} />;
};
export default EmojiPicker; |
@saurabhmehta1601 |
Any update on using If we are no longer supposed to use it (looking at the examples, seems like it), can we get an example of the "correct" way to use |
Have you tried using the custom HTML element |
@EtienneLem so I tried that and it does work (I have an example below), but I think the main point we are calling out is that we can still access
and it returns a React component that just fundamentally doesn't work (and blows up with the error above). It seems as a whole like this library moved away from React components (which is your prerogative to do), it's just confusing that we can still access them, but they don't "work" and there's no way that we can find to make them work. If this library chooses to no longer support React, that's totally cool... just please remove the ability for us to import something that looks like it should work. For those who run into this issue, I created a custom component that wraps the Depending on your use case, it likely needs to be changed or improved on, and this is essentially a PoC, but as I just need to show the emoji, this worked good enough for me (NOTE: your mileage may vary as there are some interesting default styles being applied to the emoji itself that might cause issues).
|
Right, ok. Again, all because of lack of documentation. Broken record here, but sorry for not having properly updated docs yet. Very soon, I promise. A few things: 1. init
2. This is not a React component. This is an HTMLElement and can therefore be used with React (and any other web framework).
|
@EtienneLem thanks for the update. The confusing part for us was that
used to be a valid React component and is still exported (which I think you were alluding to, no longer needs to be the case). Totally can appreciate that this is likely a lack of documentation that is causing confusion :). A few questions for you
|
Correct! Even if you were to call it multiple times, it wouldn’t currently change anything. That’s an issue that is going to be addressed in #588.
I wouldn’t necessarily mind exporting a |
@EtienneLem FWIW, for your answer to 2, you are describing a relatively common pattern in React that follows the Provider pattern using the internal context library. To be honest, I kind of have to make it all work in React and your answer to 1 means that I can follow that pattern. Are you amenable to me creating a PR that creates the Provider, Picker, and Emoji React component within this repo? Also, while I am not the OP, I think this issue can be closed. While yes, this does explode when trying to use it this way, this is a known and expected part of the v5 upgrade and we have answered how to solve it. |
Sure thing! 🤗 |
React issues have been addressed in v5.2.0. You can use See https://github.com/missive/emoji-mart#-emoji-component for the |
It says "Property 'em-emoji' does not exist on type 'JSX.IntrinsicElements'" on next.js. How do I fix this warning? |
I added the following to
|
Can you integrate this into the package ? I have to paste it every time when I pull my repo |
Could anyone tell me, where should I paste this? what folder and filename should it be? For now, I've tried |
Problem
When "Emoji" Component use with Next.js (SSR), the Error has been occurred like below.
Reference
However, "Picker" component is available for Next.js
Example code is here.
#575 (comment)
Environment
The text was updated successfully, but these errors were encountered: