kazzkiq / CodeFlask

A micro code-editor for awesome web pages.
https://kazzkiq.github.io/CodeFlask/
MIT License
1.07k stars 120 forks source link

Modify css support check to work better with SSR #92

Closed johnnyeric closed 5 years ago

johnnyeric commented 5 years ago

Hi @kazzkiq. Thanks for this project, it's great!

I've been experimenting the editor with Next.js and found an issue when using SSR on the CSS check.

It's a very simple fix but I took the liberty of creating this pull request.

Thank you

kazzkiq commented 5 years ago

Hello @johnnyeric, glad you liked CodeFlask!

Care to elaborate a little more about the issue with Next.js?

Shouldn't CSS be undefined both in client and SSR if it doesn't exists? In this case, the if(CSS) should handle both cases, why isn't it the case for Next.js?

johnnyeric commented 5 years ago

Sure, the problem is that when rendering on the server it seems the variable is not even declared so it throws when trying to access it in the if(CSS).

Then the typeof handles both cases, when it is not declared and when it is declared but is undefined.

The error message I get is CSS is not defined.

kazzkiq commented 5 years ago

Now it makes sense, merging it.

Thanks for the PR!