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.

flowtyped props, how?

See original GitHub issue

Is this right?

/* @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} />;

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
mxstbrcommented, Nov 23, 2016

That LGTM, I wonder if flow understands propTypes? /cc @ryyppy @relekang

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};
`;

Text.propTypes = {
  bold: React.PropTypes.bool,
}
0reactions
dbertellacommented, Jan 12, 2017

@steida your solution seems working fine, I’m wondering, do you know why you have to wrap the styled-component in a functional one to make it working with flow?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Components | Flow
Learn how to type React class components and stateless functional components with Flow.
Read more >
How to efficiently type your styled-components with Flow
Adding Flow on top of styled components to avoid misusages before they hit production, and make developers' and designers' life easier.
Read more >
What is the correct Flow type for the navigation props ... - GitHub
I'm trying to register a screen to a StackNavigator: const SignUpRootNavigator = StackNavigator({ Approval: { screen: Approval }, }); And I ...
Read more >
Flow type of Navigation Screen components [React Navigation]
I tried to import type NavigationScreenProp or NavigationScreenProps from @react-navigation/native but Flow announces that there is no such type ...
Read more >
Flow - Redux Form
This will give you the types of the props that will be injected into your decorated form component by the reduxForm() higher order...
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