jsx-eslint/eslint-plugin-react

`react/no-unstable-nested-components` does not allow ignoring only object properties

Open

#3 482 ouverte le 4 nov. 2022

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (2 797 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (8 630 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

I would like to keep this rule active but disable it for object properties, I have this:

function MyComponent() {
  return (
    <p>
      {intl.formatMessage(messages.allSelected, {
        size: selectedEvents.size,
        b: chunks => <b>{chunks}</b>, // <-- report error here without `allowAsProps`
      })}
    </p>
  );
}

But adding the allowAsProps: true option allows me to do things like this:

<Dropdown
  Trigger={({ onClick }) => ( // <-- don't report error here with `allowAsProps`
    <button type="button" onClick={onClick}>
      Bla bla
      <span className="caret" />
    </button>
  )}
>
  {/* ... */}
</Dropdown>

Guide contributeur