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.

Better flow support?

See original GitHub issue

Based on #240

Currently something like this works

/* @flow */
import React from 'react';
import styled from 'styled-components';

type Props = {
  bold?: bool,
};

const Text = styled.span`
  color: ${props => props.theme.colors.black};
  font-family: ${props => props.theme.fontFamily};
  font-size: ${props => props.theme.fontSize.text};
  font-weight: ${props => props.bold ? props.theme.fontWeight : 'normal'};
  line-height: ${props => props.theme.lineHeight};
`;

export default (props: Props) => <Text {...props} />;

Would it be better if we could do something like so?

Props = {
  bold?: bool,
};

const default Text = styled.span(Props)`
  color: ${props => props.theme.colors.black};
  ...
`;

//or

const default Text = styled.span({bold?: bool})`
    color: ${props => props.theme.colors.black};
  ...
`;

Just kinda annoying to make another stateless. Thoughts?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:32
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
malekjaroslavcommented, Sep 26, 2017

This would be really great. I managed to make it work by this:

//@flow
import styled from 'styled-components';
import type { ComponentType } from 'react';

const Text: ComponentType<{bold: boolean, style: Object}> = styled.span`
   font-weight: ${props => props.bold ? props.theme.fontWeight : 'normal'};
`

But then I have an issue with .extend and other methods.

12reactions
Sjiepcommented, Jan 11, 2018

Are there any new thoughts on this topic? I’m struggling to make props for a styled-component work properly together with Flow. The workaround provided by @malekjaroslav works however this breaks:

  • the usage of defaultProps,
  • props showing up properly in react-styleguidist.

I still use the workaround given in the original post

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Optimize Cura Support Settings - All3DP
Cura offers a powerful range of settings to play with. Learn about the main Cura support settings and how to best support your...
Read more >
How to Get the Best Support Settings For Filament 3D Printing ...
In this article, I'll try to explain what support settings are and how you can get the best support settings for your 3D...
Read more >
Detailed Cura Support Settings - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >
Better Flow - GitHub
Only ROS frontend supports reading data from the camera. Some useful ROS links: ROS Kinetic installation · ROS Tutorials. Setup with ROS frontend....
Read more >
9 Best Prostate Supplements [2022] - Bens Natural Health
After six months, urine flow rate and IPSS ratings improved and reduced ... to improve prostatitis symptoms and support a healthy prostate.
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