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

Rule jsx-key fails when using spread operator #122

Closed
PierreGUI opened this issue Nov 3, 2017 · 3 comments
Closed

Rule jsx-key fails when using spread operator #122

PierreGUI opened this issue Nov 3, 2017 · 3 comments

Comments

@PierreGUI
Copy link

Sometimes I like to squeeze my props and use the spread operator to pass then from parent to children components.
Not that it matters a lot but here I found the rule failing:

const List: React.SFC<ListProps> = ({list}) => (
    <div>{list.map((elt, key) => <Child {...{elt, key}} />)}</div>
  )
}

Will throw Missing "key" prop for element. (jsx-key)

Thanks.

@onzag
Copy link

onzag commented Jan 10, 2020

I have the same issue this issue should be reopened.

The key property is missed if it comes within an interface of its own.

export interface ISearchResult {
  type: string;
  id: number;
}
interface ISearchResultWithPopulateData extends ISearchResult {
  providerProps: {
    key: string;
    forId: number;
    itemDefinition: string;
    optimize: {
      onlyIncludeProperties?: string[],
      onlyIncludeIncludes?: string[],
      excludePolicies?: boolean,
      cleanOnDismount?: boolean,
    }
  };
}

When passing it to my Provider as

loader.searchResults.map((result) => {
  return (
      <ItemDefinitionProvider
        {...result.providerProps}
      >
                      
      </ItemDefinitionProvider>
    );
})

I get the same issue of missing key property.

@onzag
Copy link

onzag commented Jan 10, 2020

image

@adidahiya
Copy link
Contributor

This library is being deprecated, see #210

@adidahiya adidahiya reopened this Jan 13, 2020
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