Hello,
I’m upgrading React UIKit from v2 to v3 and got an error message ReferenceError: Element is not defined
My project enviroments following:
- Nextjs: ^12.1.2,
- React: ^17.0.2,
- @sendbird/uikit-react: ^3.1.0
Hello,
I’m upgrading React UIKit from v2 to v3 and got an error message ReferenceError: Element is not defined
My project enviroments following:
@Sravan_S Hi Sravan,
My project is using Nextjs and having problem as above when integrating React UIKit v3. Can you help me to solve this?
Thank you.
Hello @minhdat97
ReferenceError: Element is not defined is not very useful, can you share the full trace? or even a minimum reproducible repo in codesandbox/github?
Let me see what I can find
Can you see if this sample works for you?
Before, dynamic import of component used to work. Somehow it stopped working from 12.xx?
I changed to import dynamic for Channel, ChannelList, Provider and it worked. How about hooks, for example useChannelContext
, how I can dynamic import it?
When I checked
import { useChannelListContext } from "@sendbird/uikit-react/ChannelList/context";
These worked fine
cc @Tyler incase if we get similar questions
Yep, I fixed.
Thank you so much.
I had this issue with <Channel>
. After importing dynamically, I’m having trouble passing props in the the component.
How I imported based on code above:
const Channel = dynamic(import("@sendbird/uikit-react/Channel"), {
ssr: false,
})
See attachements:
I looked through the uikit code in github and was able to resolve by doing the following:
import { ChannelContextProps } from '@sendbird/uikit-react/Channel/context'
const Channel = dynamic(import("@sendbird/uikit-react/Channel"), {
ssr: false,
})
const channelProps: ChannelContextProps = {
channelUrl: CHANNEL_URL,
replyType: 'QUOTE_REPLY',
disableUserProfile: true,
isMessageGroupingEnabled: true,
}
return (
<SendbirdProvider
appId="XXXXX"
userId="sendbird"
nickname="sendbird"
>
<Channel {...channelProps} />
</SendbirdProvider>
)
Hmm, this never happened on my sample projects…
Let us investigate. Can you share your project config?