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

129
Views
Cómo cambiar la variante de la tipografía con la condición de que el texto sea demasiado largo

Soy nuevo en el uso de Material UI con ReactJs, TypeScript y trato de reducir el tamaño de fuente de la tipografía cuando su texto es demasiado grande (3 o más líneas). Aquí está mi fragmento de código:

 const x =() => { if(text.length > 12 ) return "body1"; else return "subtitle2"; }; const renderTitle = () => { return ( <Typography variant= {x} textAlign="center" lineHeight={1.2}> {text} </Typography> ); };

Pero su error dado como

 Type '() => "subtitle2" | "body1"' is not assignable to type '"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | undefined'.

¿Hay alguna forma de cambiar variant="body1" cuando el texto aparece en la tercera línea? por favor, ayúdame

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pruebe variant={x()} , porque x en su caso es una función.

about 4 years ago · Juan Pablo Isaza 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!