talkjs / country-flag-emoji-polyfill

Add country flag emojis to Chromium-based browsers on Windows
Other
140 stars 9 forks source link

0.1.5 breaks Next.js apps - add README note on typeof window check #11

Closed rookbreezy closed 9 months ago

rookbreezy commented 9 months ago

0.1.4:

polyfillCountryFlagEmojis()

0.1.5:

Make sure to check for window if doing server side rendering. if (typeof window !== 'undefined') polyfillCountryFlagEmojis()

rookbreezy commented 9 months ago

Or add window check in the code, just one line needed I think.

eteeselink commented 9 months ago

Thanks for your report.

I'm confused that it worked at all in 0.1.4. I think it would've errored out right when you imported the library, no? Reading this code sure makes it seem so. Can you confirm that this is true?

rookbreezy commented 9 months ago

I think it would've errored out right when you imported the library, no? Reading this code sure makes it seem so.

I'm guessing it throws inside the try catch, before ctx is set, then returns early.

eteeselink commented 9 months ago

ahyes, ofc. thanks. gross, but i guess it works :)

i remember having to do hacks to avoid that in our work setup but maybe our work setup is particularly quirky in this regard :)

anyway! i published a 0.1.6 which should fix this by simply returning false when window is undefined

eteeselink commented 9 months ago

can you confirm that it solves matters adequately?

rookbreezy commented 9 months ago

Fixed now in my Next.js app