Skip to content

Commit

Permalink
Add missing type for TextInput.readOnly in Typescript (#39281)
Browse files Browse the repository at this point in the history
Summary:
The `readOnly` prop is available in the `TextInput` implementation (see [usage https://github.com/facebook/react-native/issues/1](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1646), [usage https://github.com/facebook/react-native/issues/2](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1671)), but the corresponding Typescript type is currently missing. Those who use Typescript get an invalid prop error when using the `readOnly` prop on `TextInput`.

Having this prop type included in TypeScript would fix the bug above and also would be beneficial for consistency and comprehensive type support.

Notably, this prop is also included in the Flow types [here](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js#L814).

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - Add missing type for TextInput.readOnly in Typescript

Pull Request resolved: #39281

Test Plan: N/A

Reviewed By: rshest

Differential Revision: D48955477

Pulled By: NickGerleman

fbshipit-source-id: 9d3431351b8ad65a4d2fc57939b98c167dc70cee
  • Loading branch information
antliann authored and facebook-github-bot committed Sep 5, 2023
1 parent 735f4ed commit deb8185
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,11 @@ export interface TextInputProps
*/
placeholderTextColor?: ColorValue | undefined;

/**
* If `true`, text is not editable. The default value is `false`.
*/
readOnly?: boolean | undefined;

/**
* enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
* Determines how the return key should look.
Expand Down

0 comments on commit deb8185

Please sign in to comment.