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.

Component references in object-notation styles

See original GitHub issue

Per the conversation with @mxstbr in spectrum, I’ve gotten nested selectors and media queries working with the new object-notation, but not Component references like ${Text}.

Here’s my Sandbox for an example (check out the ObjectTest file): https://codesandbox.io/s/xz9q6ovvlo

Reproduction

Expected Behavior

  • <Text> component has red text

Actual Behavior

  • <Text> component has purple text

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
thysultancommented, Oct 23, 2018

Maybe a ToString method on the component could implicitly extract this when used as an object key.

function a () {}
a.toString = () => { return '.' + this.styledComponentId }
var obj = {[a]: ''}
1reaction
probablyupcommented, Oct 22, 2018

Here is a workaround: https://codesandbox.io/s/yv8ojjr5wj, but it relies on internals. I suppose we could add a util to make the pattern a little neater:

import styled, { getSelector } from 'styled-components';

const Thing = styled.div({
  color: 'red',
});

const OtherThing = styled.div({
  [getSelector(Thing)]: {
    color: 'blue',
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Component Reference - Red Hat on GitHub - JBoss.org
A reference guide to the components of the RichFaces 4 framework ... be serialized in JavaScript Object Notation ( JSON ) and returned...
Read more >
Specifying bindings in an SCA environment - IBM
Services and references enable a component to communicate with other applications. ... The product supports the following binding types: SCA binding.
Read more >
Working with objects - JavaScript - MDN Web Docs - Mozilla
Comparing objects​​ In JavaScript, objects are a reference type. Two distinct objects are never equal, even if they have the same properties. ...
Read more >
Component Reference object
Use the Component Reference object to programatically retrieve and query all the components which use or are used by a specific component.
Read more >
RFC 8259: The JavaScript Object Notation (JSON) Data ...
Code Components extracted from this document must include Simplified BSD License ... JSON can represent four primitive types (strings, numbers, booleans, ...
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