Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
Falta la definición del componente para mostrar el nombre react/display-name

¿Cómo agrego un nombre para mostrar a esto?

 export default () => <Switch> <Route path="/login" exact component={LoginApp}/> <Route path="/faq" exact component={FAQ}/> <Route component={NotFound} /> </Switch>;
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Exportar una función de flecha directamente no le da al componente un displayName , pero si exporta una función normal, el nombre de la función se usará como displayName .

 export default function MyComponent() { return ( <Switch> <Route path="/login" exact component={LoginApp}/> <Route path="/faq" exact component={FAQ}/> <Route component={NotFound} /> </Switch> ); }

También puede poner la función en una variable, establecer el displayName en la función manualmente y luego exportarla.

 const MyComponent = () => ( <Switch> <Route path="/login" exact component={LoginApp}/> <Route path="/faq" exact component={FAQ}/> <Route component={NotFound} /> </Switch> ); MyComponent.displayName = 'MyComponent'; export default MyComponent;
over 4 years ago · Santiago Trujillo Report

0

tldr: cambie la función de flecha a una función con nombre

Se muestra un error de pelusa: Component definition is missing display name react/display-name .

Para resolver, puede nombrar su función (IOW, no use la función de flecha). En este ejemplo, estoy usando react-table y pasando un componente personalizado para representarlo en una celda.

No hay error:

 { Cell: function OrderItems({ row }) { return ( <a> View Items </a> ); }, }

Error:

 { Cell: ({ row }) => ( <a> View Items </a> ) }
over 4 years ago · Santiago Trujillo Report

0

Una forma de agregar la propiedad displayName a la función de componente anónimo sin crear una función con nombre es usar recompose :

 import { compose, setDisplayName } from 'recompose'; export default compose(setDisplayName('SomeComponent'))(props => ...);

O solo:

 export default Object.assign(props => ..., { displayName: 'SomeComponent' });
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!