【Bug Report】"Emoji" component is not working for Next.js
See original GitHub issueProblem
When “Emoji” Component use with Next.js (SSR), the Error has been occurred like below.
Unhandled Runtime Error TypeError: Class constructor $8b28a44b07620e42$export$2e2bcd8739ae039 cannot be invoked without ‘new’
const Emoji = dynamic<EmojiProps>(
() => import("emoji-mart").then((m) => m.Emoji),
{
ssr: false,
}
);
export const Foo = () => {
return (
<Emoji emoji={"thinking_face"} size={64} />
);
};
Reference
However, “Picker” component is available for Next.js
const Picker = (props = {}) => {
const ref = useRef()
useEffect(() => {
import('emoji-mart').then((EmojiMart) => {
new EmojiMart.Picker({ ...props, data, ref })
})
}, [])
return <div ref={ref}/>
}
Example code is here. https://github.com/missive/emoji-mart/issues/575#issuecomment-1111323710
Environment
- next v12.1.6
- Node.js v14.19.0
- TypeScript v4.7.3
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:19 (5 by maintainers)
Top Results From Across the Web
image component in next js is not working in development build
Describe the bug. I tried to preview my web app.. in my local machine I was using the image component but the image...
Read more >Advanced Features: Error Handling - Next.js
Error Handling. This documentation explains how you can handle development, server-side, and client-side errors. Handling Errors in Development.
Read more >Blog - Next.js 7
Better error reporting with React Error Overlay ... The problem in doing this is that Next.js its URL structure did not match the...
Read more >Dynamic Imports for Components - Improving your Core Web ...
Let's run another Lighthouse report in Chrome DevTools to verify. We are left with this two optimization suggestions: Use HTTP2: to solve this...
Read more >module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any update on using
Emoji
directly in React in next (FWIW, this is the same error without using Next.js. Just referencing theEmoji
component in React throws the same error).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
Emoji
inside React?@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.