Rakin Khan
Rakin Khan

Reputation: 29

Has anyone figured out the best way to use CSS in a React component when using Deno?

So I decided on taking it upon myself to make a React template with Deno as the backend. So far its been a good balance between learning something that is familiar (React) and new (Deno). Ultimately I would like to make it usable so that anyone using React can download it and get right in. With that said, there is one issue I am having and its with CSS.

While I can import the components CSS into my component, Deno does not recognize it when running the server. It will throw an "Unknown MediaType" error. So far there is only 2 workarounds I've found:

  1. Use inline styling and turn the CSS for that attribute into an object.
  2. Put all the CSS into the static file thereby making the file longer.

Personally I would choose the second option than the first because at least I could use stuff like media queries. I have tried using the ESM version of the "styled-components" module yet that doesn't work either. Can anyone share what they have been doing?

Upvotes: 0

Views: 216

Answers (1)

Rakin Khan
Rakin Khan

Reputation: 29

Solved it.

I ended up using the ESM version of the "styled-components" module and then set up the server-side rendering in the response body. Cant believe this gave me 2 weeks of headaches.

Upvotes: 1

Related Questions