question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Queries in emotion css blocks have broken types

See original GitHub issue

Hi Maxim!

First of all: many thanks for such a great library 😃

I am writing as I have stumbled upon a potential bug that relates to Typescript.

the following line of code will result in a Type Error

import { css } from "@emotion/react";
import { down } from "styled-breakpoints";

const myReusableCss = css`
  ${down("xs")}{
    background: red;
  }
`

you can check the reproduction in a Code Sandbox:

https://codesandbox.io/s/stupefied-hertz-0z2b6?file=/src/MyComponent.ts

I might take a deeper look into code later on in the week to see whether I could come up with a solution.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mg901commented, May 31, 2021

@filipnathanel In the near future I will investigate this issue and try to solve your problem.

1reaction
filipnathanelcommented, May 26, 2021

Or maybe I just don’t understand emotion’s API 🤷‍♂️ …

I made it work by explicitly passing props from the outer scope, which I assumed would be done automatically for string interpolations within css blocks

import { css } from "@emotion/react";
import { down } from "styled-breakpoints";

const myReusableCss = (props) => css`
  ${down("xs")(props)}{
    background: red;
  }
`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Media Queries - Emotion
Using media queries in emotion works just like using media queries in regular css except you don't have to specify a selector inside...
Read more >
Why We're Breaking Up with CSS-in-JS - DEV Community ‍ ‍
Hi, I'm Sam — software engineer at Spot and the 2nd most active maintainer of Emotion, a widely-popular CSS-in-JS library for React.
Read more >
media query display block not working in @emotion/react
I have a style like this. //inside page.jsx export function Page() { return ( <div css={container}> <div css={header}> <div ...
Read more >
styled-breakpoints | Yarn - Package Manager
Simple and powerfull css breakpoints for styled-components and emotion. media, query ... Simple and powerful tool for creating media queries with.
Read more >
How to use media queries with styled components
Media queries with styled components work the same as in CSS! const CardWrapper = styled.div` display: flex; flex-direction: row; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found