StyledComponent ThemeWrapper 0.91 -> 0.92
See original GitHub issueHey,
We’re using:
- flow-typed: styled-components_v4.x.x.js (8ae4cfa383fc58443d8d65b5301bf1c1)
- With the styleguide feature ThemeProvider wrapper
We’ve been using flow-bin v0.91.0
, upgrading to either v0.92.0
or v0.93.0
results in a flood around use of theme, which had never appeared before.
export default () => (
<ThemeProvider theme={OurTheme}>
<Page />
</ThemeProvider>
)
OurTheme contains things like breakpoint shortcuts that we use like this:
const PageWrapper = styled.div`
margin-top: 6.8rem;
@media ${({ theme }) => theme.breakpoint.onlyScreen.tablet} {
margin-top: 7rem;
};
@media ${({ theme }) => theme.breakpoint.onlyScreen.laptop} {
margin-top: 12rem;
};
`;
This is giving us flow errors like this:
Cannot call styled.div because:
• property theme is missing in object type [1] in the first argument of array element.
• property theme is missing in object type [1] in the first argument of array element.
src/App/Component/Pages/Page.jsx
10│
11│ const PageWrapper = styled.div`
12│ margin-top: 6.8rem;
13│ @media ${({ theme }) => theme.breakpoint.onlyScreen.tablet} {
14│ margin-top: 7rem;
15│ };
16│ @media ${({ theme }) => theme.breakpoint.onlyScreen.laptop} {
17│ margin-top: 12rem;
18│ };
19│ `;
20│
flow-typed/npm/styled-components_v4.x.x.js
[1] 9│ | (<P: {}>(executionContext: P) => string)
- Anyone have any idea what would have changed to get flow bin to handle these differently in >0.92.0?
- Is this styled-components flow-typed def presently able to handle themes?
- If there’s a breaking change and I need to start providing a definition of my theme object, I have a Generic type ready to go, anyone have any idea where the best (and hopefully DRY-est) place is to declare this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:13 (5 by maintainers)
Top Results From Across the Web
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 >styled-components-theme-provider - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >How to use Themes in styled-components - DEV Community
jsx the component, we now import the theme component that was just created to wrap our entire function. By wrapping our App function,...
Read more >styled-components-theme-connector - npm
Start using styled-components-theme-connector in your project by running ... Wrap root component with a default theme config: const theme ...
Read more >Can't get Jest to work with Styled Components which ... - GitHub
Personally I provide default props to any styled component using the theme, e.g: const Wrapper = styled.div` color: ${props ...
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
More discussion here: https://github.com/flow-typed/flow-typed/pull/3126