reactjs / reactjs/react-docgen

HOC as a function won't get generated docs

Aperta
#205 9 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
3.8k
Fork
316
Merge medio
5h 7m
PR unite (30g)
4

Descrizione

Similar to #177 but a slightly different scenario...

Given a HOC method like so:

import { bool } from 'prop-types';

const withSomeExtraProps = Wrapped => {
  class HigherOrderComponent extends Component  {
    static propTypes = Object.assign({}, Wrapped.propTypes, {
      /**
       * This should be picked up in the docgenInfo
       */
      anExtraProp: bool,
    });
    static defaultProps = Object.assign({}, Wrapped.defaultProps, {
      anExtraProp: false,
    });
    // ....the rest of the HOC logic
  }
  return HigherOrderComponent;
}

export default withSomeExtraProps;

I understand that this wouldn't automatically mean that the export default withSomeExtraProps(Wrapped) wouldn't automatically get the docgenInfo from the HOC added, but I thought individually this HOC would have it's own docgenInfo that I could reference on it's own.

However, it seems the inner component class here doesn't get recognised and parsed. Does the component class need to be exported for the parser to find it?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l’esempio HOC nell’issue e segui come il parser gestisce la classe del componente interno. Conferma il comportamento previsto di docgenInfo e aggiungi una copertura che mostri che la prop aggiuntiva dell’HOC viene riconosciuta; il report non indica file né test esistenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, react
Ambito
documentation, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.