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

Destructuring a value off of a stateless function causes false prop-types error #782

Closed
kentcdodds opened this issue Aug 22, 2016 · 0 comments
Labels

Comments

@kentcdodds
Copy link
Contributor

As noted in #735:

Here's how I can reproduce the issue:

import React, {PropTypes} from 'react'

function Foo({bar}) { // react/prop-types error reported for bar on this line
  const {baz} = Foo
  return <div>{baz} {bar}</div>
}

Foo.propTypes = {
  bar: PropTypes.string.isRequired,
}

Foo.baz = 'hi'

This does not produce any error:

import React, {PropTypes} from 'react'

function Foo({bar}) {
  const baz = Foo.baz
  return <div>{baz} {bar}</div>
}

Foo.propTypes = {
  bar: PropTypes.string.isRequired,
}

Foo.baz = 'hi'

Here's a real use case

Looks like destructuring a property off of the function (whether inside the function itself or not) is causing issues.

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

No branches or pull requests

2 participants