Skip to content

jsxImportSource not working on cra #2752

Closed
@testerez

Description

@testerez

Current behavior:

I followed the Typescript instructions to add emotion to a fresh create-react-app project: testerez/cra-ts-emotion@086cc35

But when I try to use css prop in any way:

<div>
  <div css={{ color: "red" }}>Hello!</div>
  <div css={css({ color: "red" })}>Hello!</div>
  <div
    css={css`
      color: red;
    `}
  >
    Hello!
  </div>
</div>

Here is the result I get:

<div>
  <div css="[object Object]">Hello!</div>
  <div
    css="You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."
  >
    Hello!
  </div>
  <div
    css="You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."
  >
    Hello!
  </div>
</div>

Did I miss something?

To reproduce:

  1. checkout this sample project https://github.com/testerez/cra-ts-emotion
  2. run npm i && npm run start

Expected behavior:

I would expect the css prop to work with this setup.

Environment information:

  • react version: 18.1.0
  • @emotion/react version: 11.9.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions