Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberInput doesn't support TextField props #2933

Closed
3 of 7 tasks
adamzolyak opened this issue Feb 4, 2024 · 1 comment
Closed
3 of 7 tasks

NumberInput doesn't support TextField props #2933

adamzolyak opened this issue Feb 4, 2024 · 1 comment
Labels
bug a bug in one of the components

Comments

@adamzolyak
Copy link

adamzolyak commented Feb 4, 2024

Description

For some reason, I can't add TextField props to NumberInput.

Example

Type '{ initialNumber: number; onChangeNumber: (value: NumberInputData) => void; placeholder: string; enableErrors: true; validate: string[]; validationMessage: string[]; showCharCounter: true; maxLength: number; }' is not assignable to type 'IntrinsicAttributes & _NumberInputProps & RefAttributes<TextFieldProps>'.
  Property 'placeholder' does not exist on type 'IntrinsicAttributes & _NumberInputProps & RefAttributes<TextFieldProps>'.ts(2322)

The docs indicate NumberInput should support TextField props.

I also see TextFieldProps defined in the type for NumberInput

const NumberInput: React.ForwardRefExoticComponent<_NumberInputProps & React.RefAttributes<TextFieldProps>>

So not sure why it's not working.

Perhaps related to #2515 RE #2515 (comment)?

Related to

  • Components
  • Demo
  • Docs
  • Typings

Steps to reproduce

Steps to reproduce the behavior:

  1. Add a NumberInput
  2. Try adding a placeholder prop
  3. Obseve the error (see above)

Expected behavior

  1. Add a NumberInput
  2. Try adding a placeholder prop without error
  3. Add additional TextFieldProps props

Actual behavior

See steps to reproduce.

More Info

Code snippet

 <NumberInput
          initialNumber={weightValue}
          onChangeNumber={(value) => {
                //TODO:
          }}
          placeholder={'weight value in LBS'}
/>

Environment

  • React Native version: 18.2.0
  • React Native UI Lib version: 7.16.0
  • VS Code Version: 1.85.1 (Universal)

Affected platforms

  • Android
  • iOS
  • Web
@adamzolyak adamzolyak added the bug a bug in one of the components label Feb 4, 2024
@M-i-k-e-l
Copy link
Contributor

Hi @adamzolyak,

That was a bug in the docs (now fixed), NumberInput does not actually extend TextField but has a textFieldProps prop where you can send most of the relevant props (the ones you cannot send directly to NumberInput itself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in one of the components
Projects
None yet
Development

No branches or pull requests

2 participants