Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Creating an interface for react-native dynamic component (wrapper element)
export interface IWEProps {
  accessibilityLabel: string;
  onPress?: ((status: string | undefined) => void) | undefined;
  localePrefix: string;
  children: JSX.Element[];
  style: IWEStyle;
  type?: string;
}

class WrappingElement extends  React.PureComponent<IWEProps> {
  render() {
    const {
      onPress, children, type, accessibilityLabel, style,
    } = this.props;

    return onPress ? (
      <TouchableOpacity
        accessibilityLabel={accessibilityLabel}
        style={style}
        type={type}
        onPress={() => onPress(type)}
      >
        { children }
      </TouchableOpacity>
    ) : (
      <View
        accessibilityLabel={accessibilityLabel}
        style={style}
        type={type}
      >
        { children }
      </View>
    );
  }
}

This is what I am doing, and this is an error I'm getting on type prop in View and TouchableOpacity:

Property 'type' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error message is straight forward: The prop type does not exist for the components View and TouchableOpacity. The available props for View are documented here. The available props for TouchableOpacity are documented here.

Since you are not doing anything with type in WrappingElement other than passing it to View and TouchableOpacity and the onPress function, you can just remove this prop. The following code is equivalent to yours, but does not throw the type error.

export interface IWEProps {
  accessibilityLabel: string;
  onPress?: ((status: string | undefined) => void) | undefined;
  localePrefix: string;
  children: JSX.Element[];
  style: IWEStyle;
  type?: string;
}

class WrappingElement extends  React.PureComponent<IWEProps> {
  render() {
    const {
      onPress, children, type, accessibilityLabel, style,
    } = this.props;

    return onPress ? (
      <TouchableOpacity
        accessibilityLabel={accessibilityLabel}
        style={style}
        onPress={() => onPress(type)}
      >
        { children }
      </TouchableOpacity>
    ) : (
      <View
        accessibilityLabel={accessibilityLabel}
        style={style}
      >
        { children }
      </View>
    );
  }
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda