Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-Complete in vs-code for custom button component in react using Flow.js #8131

Open
invalidtoken opened this issue Oct 10, 2019 · 1 comment

Comments

@invalidtoken
Copy link

invalidtoken commented Oct 10, 2019

I am creating a Custom Button component in React. The basic version of the component looks something like this -

// @flow
type ButtonPropsType = {};
const Button = (props: ButtonPropsType) => {
  const { children, ...rest } = props;
  return <button {...rest}>{children}</button>
}

let App = () => {
  return (
    <div>
      <Button style={{ margin: 10 }}>Sahil Kapoor</Button>
    </div>
  )
}

How should I define the type of my Button component so that VS-Code knows that my Button component accepts all the attributes of a normal React button element like style, onClick, className etc?
Right now when I use my Button component VS-Code does not know that it accepts all button attributes and hence does not show auto-complete.

@jcready
Copy link
Contributor

jcready commented Oct 11, 2019

Flow doesn't type check any props passed to (lower-case) DOM elements in React. For instance, this passes type checking:

// @flow
import * as React from 'react';
const Test = () => {
  return <button style={1} onClick={{}} className={() => {}} />
}

I'm not sure what would be providing the auto-complete for these inside vs-code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants