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

229
Views
React Native, acepte las propiedades de los componentes nativos como accesorios y tenga otros personalizados con una interfaz de TypeScript

Tengo este componente AppText en el que quiero usar una interfaz Props mientras tengo la capacidad de aceptar otros campos de accesorios que puedo consumir con un spread operator . Aquí está mi intento a continuación.

Texto de aplicación:

 import React from "react"; import { View, Text } from "react-native"; import { colors } from "../utils/config"; interface Props { fontSize?: number; color?: string; } const AppText: React.FC<Props> = ({ children, fontSize = 16, color = colors.black, ...restProps }) => { return ( <Text {...restProps} style={{ color: color, fontSize: fontSize }}> {children} </Text> ); }; export default AppText;

Cómo estoy usando mi componente:

 <AppText accessible>Not member yet ? </AppText>

El error que estoy recibiendo:

 Type '{ children: string; accessible: true; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.Property 'accessible' does not exist on type 'IntrinsicAttributes & Props & { children?: ReactNode; }'
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería poder redefinir Props , supongo que TextProps se puede importar desde react-native , así:

 interface Props extends TextProps { fontSize?: number; color?: string; }

Esto agrega TextProps a sus propiedades, el operador de propagación debe comprender qué elementos sobran.

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!