Add official support for createStyled?
See original GitHub issueI was wondering if this library could provide (or if it already does) a component that would allow to use styles with a render prop pattern, instead of the withStyles
HOC.
I searched for it, and the best I could find was this, but that’s not quite what I would’ve expected. That option would need users of this api to create a new component every time:
import { createStyled } from '???';
const Styled = createStyled({ /* styles go in here */ })
// It is supposed to be used like this:
render() {
return (
<Styled>
{({ classes }) => (
// render your thing here
)}
</Styled>
);
}
I wonder if it would be a bit better or even possible to have a generic component that receives styles and provides classes, instead of having to create one component tied to specific styles:
// would be something provided by this lib
import Styled from 'material-ui/Styled';
const styles = { /* styles go in here */ }
// Then use it like this:
render() {
return (
<Styled styles={styles}>
{({ classes }) => (
// render your thing here
)}
</Styled>
);
}
Also, as a side note, even if this suggestion is not accepted, I wonder why the createStyled
helper is not provided as an export of this library, just as withStyles
is.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Add official support for createStyled? · Issue #11047 - GitHub
I was wondering if this library could provide (or if it already does) a component that would allow to use styles with a...
Read more >styled() - MUI System
It supports the theme's styleOverrides and variants to be applied, based on the name applied in the options (can be skipped). It adds...
Read more >Advanced Usage - styled-components
styled-components has full theming support by exporting a <ThemeProvider> wrapper component. This component provides a theme to all React components ...
Read more >Using Styled Components - Expo Documentation
Using styled-components with Expo, you can create universal styles that'll work the same across web, mobile, and desktop! Getting Started. Install the Styled ......
Read more >Theme with styled-components and Typescript - Medium
This will help with IntelliSense and ensure a contract for all available themes. // styled.d.ts import 'styled-components';interface IPalette {
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
@gnapse I’m reopening as it’s a good question. I don’t have a definitive answer.
@gnapse The initial motivation was: it’s working, but it’s an extra API to support. Let’s document it and see how it’s used in the wild. Now, as people start using it and rely on it in production with no issue, I’m more confidence integrating it into the core. I have no real objection to it. It just hasn’t been a priority so far. You know, extending the API comes with overhead: documentation, tests, maintenance, etc.