Overriding
See original GitHub issueFor some reason I thought this would work:
const Block = styled.div`
background-color: blue;
color: white;
`;
// Override Block and give it a red background, using all other styles (i.e. just adding another class that overrides the background-color
const EmergencyBlock = styled(Block)`
background-color: red;
`;
Can we make this work? That would be a great overriding mechanism.
Issue Analytics
- State:
- Created 7 years ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
Overriding in Java - GeeksforGeeks
In any object-oriented programming language, Overriding is a feature that allows a subclass or child class to provide a specific ...
Read more >Overriding Definition & Meaning - Merriam-Webster
The meaning of OVERRIDING is chief, principal. How to use overriding in a sentence.
Read more >Java - Overriding - Tutorialspoint
In object-oriented terms, overriding means to override the functionality of an existing method. Example. Let us look at an example. Live Demo. class...
Read more >Method Overriding in Java - javatpoint
If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java. In...
Read more >Overriding and Hiding Methods (The Java™ Tutorials ...
The ability of a subclass to override a method allows a class to inherit from a superclass whose behavior is "close enough" and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to attach the class:
styled-components
injects a class with the given styling. If you don’t attach it to a DOM node, you’re not attaching it a DOM node, so it can’t be in the DOM!would it be possible pass the desired className to the styled function ? Maybe this is more a feature request. i.e.
I don’t like that my component has to behave (attach the custom className) as
styled
wants it to. I think the component should be agnostic.