Element is not defined

Hello,

I’m trying to implement Sendbird-uikit but I’m having a problem right at the build:

I’ve tried with sendbird-uikit v1.2.8 and with 1.3.0 but I still have the same error.
I’m using:

  • next 10.0.3
  • react 17.0.1
  • react-dom 17.0.1
  • NodeJS v15 (I’ve tried with v12 also)

I’ve also tried with sendbird-uikit 2.0.0-alpha.0 but this time I get this error:
/Users/janick/Projects/clients/livedesigners/livedesigners-app/node_modules/sendbird-uikit/dist/esm/index.js:1
export { g as getStringSet, w as withSendBird } from ‘./LocalizationContext-619bafba.js’;
^^^^^^

SyntaxError: Unexpected token ‘export’
at wrapSafe (node:internal/modules/cjs/loader:999:16)
at Module._compile (node:internal/modules/cjs/loader:1047:27)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1112:10)
at Module.load (node:internal/modules/cjs/loader:948:32)
at Function.Module._load (node:internal/modules/cjs/loader:789:14

Anyone knows how to fix this problem?

Best,

Janick

Hello, Can you share your implementation (with 1.3.1)?

And for sendbird-uikit 2.0.0-alpha.0 it looks like you are trying to import our esm module(which is in sendbird-uikit/dist/esm/index.js) as a CommonJS module. Anyways, we will be changing the import structure a little, so, we still recommend using v1.3.x

https://codesandbox.io/s/cocky-hawking-h3zbs this is a sample we have for nextJS

So, the idea is that for using UIKit has a lot of dynamic data in it, so we have to dynamically-import UIKit

Hello Sravan,

Thank you for your replies.

I’ve spotted two things required to make it work with NextJS. First one is indeed the dynamic import, and the second one is that sendbird-uikit isn’t compatible with React (react and react-dom) above 16.13.1.

For anyone having a similar problem, check in the package-lock that you don’t have any dependencies using React above 16.13.1 as sometimes 16.14.0 is used and is causing problems.

Best,

Janick

Hm, interesting! Sometime before, we have checked with 16.14.0 and 17.0.0 and the library worked fine. Can you share the error log when you tried 16.14.0?

Hello,

I’ll try to test it again and give you more information as soon as I’m less busy with the implementation (pretty urgent project :wink: )

Best,

Janick

1 Like