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

220
Views
React Native, accept native component properties as props and have custom ones with a TypeScript interface

I have this AppText component where I want to use a Props interface while having the ability to accept other props fields that I can consume with a spread operator. Here is my attempt below.

AppText:

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;

How I am using my component:

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

The error I am getting:

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

You should be able to redefine Props, I assume TextProps can be imported from react-native, like so:

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

This adds TextProps to your properties, the spread operator should understand what elements are left over.

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!