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

forEach missing in props validation #497

Closed
inian opened this issue Mar 12, 2016 · 3 comments
Closed

forEach missing in props validation #497

inian opened this issue Mar 12, 2016 · 3 comments
Labels

Comments

@inian
Copy link

inian commented Mar 12, 2016

Plugin version - 4.2.1
forEach is considered as a prop that I need to validate instead of being recognised as an inbuilt function.
Sample code below

import React, { PropTypes } from 'react';
function JobList(props) {
  const jobs = [];
  props
  .jobs
  .forEach(() => {}); // error here saying 'forEach missing in props validation'

  return (
    <div></div>
  );
}

JobList.propTypes = {
  jobs: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.string.isRequired,
    })
  ),
};
@yannickcr yannickcr added the bug label Mar 12, 2016
@reconbot
Copy link

Same thing for .map just fyi

@ljharb
Copy link
Member

ljharb commented Mar 14, 2016

Seems like any propType that is annotated as array or arrayOf should ignore all of the Array.prototype methods.

@yannickcr
Copy link
Member

They are already ignored, but I seems there is a bug with line-breaks.

props
.jobs
.forEach(() => {}); // forEach missing in props validation

props.jobs.forEach(() => {}); // No warning

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

4 participants