Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
¿Por qué aparece "La propiedad 'ancha' no existe en el tipo 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'".

Estoy tratando de agregar componentes con estilo a mi proyecto, pero tengo algunos problemas para cambiar el estilo en función de los accesorios del componente con estilo. Cada vez que trato de hacer esto - ancho: ${(props) => (props.wide ? '100%' : undefined)}; Obtengo una Property 'wide' does not exist on type 'ThemedStyledProps<PressableProps & RefAttributes<View>, DefaultTheme>'. error.

Estoy pasando variant , wide y style al componente con estilo y tengo el tipo de accesorios definido así:

 type StyledPressableProps = { variant?: ButtonVariant; wide?: boolean; } & PressableProps;

Pero sigo recibiendo un error de TS.

Mi código:

 import React, { FunctionComponent } from 'react'; import { PressableProps, ViewStyle, StyleProp } from 'react-native'; import styled from 'styled-components/native'; import colors from '@src/core/colors'; import HeaderText from '../Text/HeaderText'; type ButtonVariant = 'primary' | 'secondary' | 'tertiary'; type Props = { title: string; variant?: ButtonVariant; wide?: boolean; style?: StyleProp<ViewStyle>; } & Omit<PressableProps, 'style'>; type StyledPressableProps = { variant?: ButtonVariant; wide?: boolean; } & PressableProps; const PrimaryButton: FunctionComponent<Props> = ({ title, variant = 'primary', wide = false, ...rest }) => { const textColor = variant === 'primary' ? colors.white : colors.primary600; return ( <StyledPressable variant={variant} wide={wide} style={({ pressed: isPressed }) => [{ elevation: isPressed ? 5 : 0 }]} {...rest} > <StyledHeaderText variant="h4" style={{ color: textColor }}> {title} </StyledHeaderText> </StyledPressable> ); }; const StyledPressable: FunctionComponent<StyledPressableProps> = styled.Pressable` padding: 12px 24px; border-radius: 100px; border-width: 1.5px; justify-content: center; align-items: center; align-self: center; width: ${(props) => (props.wide ? '100%' : undefined)}; background-color: ${(props) => styles[props.variant].backgroundColor}; border-color: ${(props) => styles[props.variant].borderColor}; `; const StyledHeaderText = styled(HeaderText)` text-align: center; `; const styles = { primary: { backgroundColor: colors.primary600, borderColor: colors.primary600, }, secondary: { backgroundColor: colors.white, borderColor: colors.primary600, }, tertiary: { backgroundColor: 'transparent', borderColor: 'transparent', }, }; export default PrimaryButton;
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda