There is no overload that matches this call in Component React with Typescript

I am struggling with an error in my placeholderTextColor and cannot seem to find a solution.

 import React from 'react';
import { TextInputProps } from 'react-native';
import { color } from 'react-native-reanimated';

import { Container, TextInput, Icon } from './styles';

interface InputProps extends TextInputProps {
  name: string;
  icon: string;
}
// All "rest" properties are passed to the TextInput, in this case only the placeholder
const Input: React.FC<InputProps> = ({ name, icon, ...placeholder }) => (
  <Container>
    <Icon name={icon} size={20} color="#666360" />

    <TextInput
      keyboardAppearance="dark"
      placeholderTextColor="#666360"
      {...placeholder}
    />
  </Container>
);
export default Input;

The error persists. If I remove the spread operator, the error disappears, but that is not a proper solution.

Full Error:

(JSX attribute) placeholderTextColor?: string | typeof OpaqueColorValue | undefined The text color of the placeholder string

No overload matches this call. Overload 1 of 2, '(props: Pick & Partial<...>, "ref" | ... 109 more ... | "showSoftInputOnFocus"> & { ...; } & { ...; } & { ...; }): ReactElement<...>', gave the following error. Type 'ColorValue' is not assignable to type 'string | unique symbol | undefined'. Type 'unique symbol' is not assignable to type 'string | unique symbol | undefined'. Overload 2 of 2, '(props: StyledComponentPropsWithAs): ReactElement, string | ... 1 more ... | (new (props: any) => Component<...>)>', gave the following error. Type 'ColorValue' is not assignable to type 'string | unique symbol | undefined'. Type 'unique symbol' is not assignable to type 'string | unique symbol | undefined'.ts(2769) index.d.ts(1626, 5): The expected type comes from property 'placeholderTextColor' which is declared here on type 'IntrinsicAttributes & Pick & Partial<...>, "ref" | ... 109 more ... | "showSoftInputOnFocus"> & { ...; } & { ...; } & { ...; }' index.d.ts(1626, 5): The expected type comes from property 'placeholderTextColor' which is declared here on type 'IntrinsicAttributes & Pick & Partial<...>, "ref" | ... 109 more ... | "showSoftInputOnFocus"> & { ...; } & { ...; } & { ...; }'

Answer №1

It appears that you are utilizing the placeholderTextColor property within TextInput, but assigning it as a string value.

Have you attempted to remove or update this assignment?

interface InputProps extends TextInputProps {
  name: string;
  icon: string;
  placeholderTextColor: color;
}

Answer №2

To resolve this issue, the solution was to incorporate the imported property into another property placeholder as shown below:

interface InputProps extends TextInputProps {
  name: string;
  icon: string;
  placeholder: string;
}
// All "rest" properties are passed to the Text Input, in this case only the placeholder
const Input: React.FC<InputProps> = ({ name, icon, placeholder }) => (
  <Container>
    <Icon name={icon} size={20} color="#666360" />
    <TextInput keyboardAppearance="dark" placeholder={placeholder} />
  </Container>
);
export default Input;

Kudos to @Someone Special for identifying the Styled Components issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Webpack is failing to recognize certain CSS files

My development stack includes Vue.js 2.5.15, Webpack 4.12.0, css-loader 0.28.11, ASP.Net Core 2.1 in Visual Studio 2017. Starting with the Visual Studio asp.net core template project for Vue and Typescript, I prefer to have individual small CSS files with ...

Identify duplicate value assignments for a property using ngOnChanges

Essentially, I am working with an array of objects and my goal is to pass the index of a selected object from the array to another component using @Input. The issue arises when I try to select the same item twice because the ngOnChanges function does not ...

The specified path is not found within the JsonFilter

Something seems off. I'm using Prisma with a MongoDB connection and attempting to search the JSON tree for specific values that match the [key, value] from the loop. However, I haven't made much progress due to an error with the path property. Be ...

What is the correct way to start a typed Object in TypeScript/Angular?

As I delve into the world of Angular and TypeScript, I am faced with a dilemma regarding how to initialize an object before receiving data from an API request. Take for instance my model: //order.model.ts export class Order { constructor(public id: num ...

Top method in Angular 6 for verifying if a scrollable section has been scrolled to the very bottom

I am searching for a reliable solution in Angular 6 to determine whether a scrollable host component has reached its maximum scroll bottom. Despite my efforts, I have been unsuccessful in finding a functioning example of a function that can detect if a cu ...

Creating custom designs for Material UI components

Although not a major issue, there is something that bothers me. I am currently using react, typescript, and css modules along with . The problem arises when styling material ui components as I find myself needing to use !important quite frequently. Is th ...

What steps can I take to ensure that Visual Studio replaces my JavaScript file during the TypeScript build process?

In my development process using Visual Studio to work on my TypeScript project, I have encountered an issue with the build process. I have a build.ts file that links to all of my other TS files and compiles them into one app.js file along with an associate ...

Creating an id automatically using MYSQL with sequelize and typescript is not possible

I recently started using typescript and I am currently following a tutorial. Most tutorials I have come across use a package to automatically generate an id for the table. My query is: Is there a way to configure sequelize to create the table id with auto- ...

A guide to testing the mui Modal onClose method

When using material UI (mui), the Modal component includes an onClose property, which triggers a callback when the component requests to be closed. This allows users to close the modal by clicking outside of its area. <Modal open={open} onCl ...

What exactly are the implications of having dual type declarations in TypeScript?

I recently came across the Angular tutorial here In the code snippet below, there are double type declarations that I am having trouble understanding. handleError<T>(operation = 'operation', result?: T) { return (error: any): Observabl ...

The error message "VueRouter does not have a property named 'history'" is common in Vue with TypeScript

In my typescript vue application, I encountered an error within a component while trying to access a parameter passed into the route. Here is the relevant code snippet: properties = getModule(PropertiesModule, this.$store); mounted() { id = this.$router. ...

ngOnInit unable to properly listen to event stream

I've been trying to solve a persistent issue without success. The problem involves the interaction between three key elements: the HeaderComponent, TabChangingService, and TabsComponent. Within the HeaderComponent, there are three buttons, each with a ...

Tips on setting a value to zero in Angular when there is no input

Is there a way to organize the data and show the PRN entries based on the date, for instance, when the month is January? If there is data for machine 1 with assetCode: PRN, it should be displayed under the header for children. Similarly, if there is data f ...

Invoke an array in PHP

If I need to call an array from PHP into TypeScript in array format, how can I accomplish this? Below is my PHP code: $AccessQuery = "SELECT name, lastname, phone, email FROM user INNER JOIN access ON id ...

Angular 2 Service's filtering functionality can be enhanced with an Array parameter

I developed a function to retrieve filtered results from a JSON dataset. getItem(id: string): Observable<any[]> { return this.http.get('path/to/my.json') .map((response) => { let results: any = response.json( ...

Executing a single method during the ngAfterViewChecked lifecycle hook in Angular

When tracking a change of variable and wanting to run a function after the change, I utilized the ngAfterViewChecked hook. However, since this method involves data submission which should only occur once, I incorporated a boolean status variable to manage ...

The `setState` function is failing to change the current value

I'm having an issue with setting State in the dropdown component of semantic-ui-react while using TypeScript in my code. The selected category value is always returning an empty string "". Any suggestions on how to resolve this problem? impo ...

Encountering ERR_INVALID_HTTP_RESPONSE when trying to establish a connection with a Python gRPC server using @bufbuild/connect

Attempting to establish a connection to a python grpc server developed with grpcio through a web browser using connect-query. Encountering an issue where upon making a request, an ERR_INVALID_HTTP_RESPONSE error is displayed in the browser. Below is the Re ...

Color key in square shape for graph legend

I am looking for legend colors in square shape, but I don't want them to appear as square boxes on the graph. https://i.stack.imgur.com/Of0AM.png The squares are also showing up on the graph, which is not what I want. https://i.stack.imgur.com/Az9G ...

Defining our own properties within a TypeScript reference interface

Is it possible to use the type of a property of an Interface as a generic in TypeScript? I have some code that demonstrates what I'm trying to achieve: In the example below, I show how we can normally define types using enums and interfaces: enum Se ...