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.

css prop returns [object, object]

See original GitHub issue
  • emotion version: "@emotion/core": "^10.0.5", "@emotion/styled": "^10.0.5",

  • react version: 16.6.3

Relevant code:


const app = css({
	'.ant-btn-primary': {
		background: colors.highlight,
	},
});

<div css={app}>...</div>


package.json

{ "name": "app", "version": "0.1.0", "private": true, "dependencies": { "@emotion/core": "^10.0.5", "@emotion/styled": "^10.0.5", "antd": "^3.11.2", "jwt-decode": "^2.2.0", "react": "^16.6.3", "react-dom": "^16.6.3", "react-router-dom": "^4.3.1", "react-scripts": "2.1.1" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ], "devDependencies": { "react-localize-redux": "^3.5.1" } }

What you did:

I am trying to upgrade from v9 to 10 and all the class imports have stopped working.

What happened:

This is the output for all classes: <div css="[object Object]">...</div>

The image below shows you the output for css. styled components work as they should.

Selection-043

I am not sure what needs to happen for all the classes to work and not emotion return an array of objects.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
harmeetjaipurcommented, Dec 19, 2018

@harmeetjaipur did you find the answer to this? Finding the same problem myself.

Adding following at top of the component files fixed it for me:

/** @jsx jsx */ import { jsx } from '@emotion/core'

Typical syntax now for adding emotion styles is:

<div css={customStyle} className="button">Submit</div>

21reactions
strasscommented, Apr 29, 2019

+1 - is there any way to not have to use pragma in a typescript project?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React styles prop returns [object object] for an array?
check your browser console - it should be generating an error along the lines of "you must pass a style object". You can't...
Read more >
The css Prop - Emotion
The function returns an object containing the computed name and flattened styles. The returned object is understood by emotion at a low level...
Read more >
object-position - CSS: Cascading Style Sheets - MDN Web Docs
The object-position CSS property specifies the alignment of the selected replaced element's contents within the element's box.
Read more >
HTML DOM Style object - W3Schools
Style Object Properties ; transition, A shorthand property for setting or returning the four transition properties ; transitionProperty, Sets or returns the CSS...
Read more >
Displaying Data with Props - From JavaScript to React - Next.js
If you console.log() props, you can see that it's an object with a title ... function Header({ title }) { console.log(title) // "React...
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