question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export types for every component like "TextInputProps"

See original GitHub issue

Hello,

in current version of react-native-paper i can not extend from TextInputProps in my custom component.

Current behaviour

No export in typescript/types.d.ts for Props definitions

Expected behaviour

export of props definitions like “TextInputProps”

Code sample

// this is not a working example - only to view, what i mean :)
import React from 'react;
import { TextInput, --> TextInputProps <-- } from 'react-native-paper';

type MyCustomInputProps = TextInputProps & {
  // ...mycustomprops
  errorMessage?: string;
}

export function MyCustomInput({errorMessage, ...inputProps}: MyCustomInputProps): JSX.Element {
  return (
    <>
      <TextInput {...inputProps} />
      <HelperText type="error" visible={!!errorMessage}>{errorMessage}</HelperText>
    </>
  )
}

// File typescript/types.d.ts
...
export { default as TextInput, TextInputProps } from './components/TextInput/TextInput';
...

Your Environment

software version
ios or android
react-native 0.64.1
react-native-paper ^4.8.1
node 16.1.0
yarn 1.22.5
react-native-vector-icons 8.1.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
r1ckyrockzcommented, May 15, 2021

Found a solution, that works for me.

Just use this import: import { TextInputProps } from 'react-native-paper/lib/typescript/components/TextInput/TextInput';

0reactions
r1ckyrockzcommented, May 15, 2021

Yes, this issue still exists with the latest version, because the types are missing in the build directory as described above 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set Up Custom Component Type That Using TextInput props ...
I get the following error: 'CustomTextInput' refers to a value, but is being used as a type here. Did you mean 'typeof CustomTextInput'?...
Read more >
TextInput - React Native
A foundational component for inputting text into the app via a keyboard. ... and different keyboard types, such as a numeric keypad.
Read more >
A guide to React design patterns - LogRocket Blog
Explore the top React design patterns, like the render props pattern and the state reducer pattern, to solve issues experienced by ...
Read more >
Time-Saving React Native TextInput Component - YouTube
In this video, we create a time-saving custom reusable textinput component with typescript. Part 4 of React Native Custom Components with ...
Read more >
React Hook Form for React Native - Echobind
Optionally, you can also pass along any validation rules , and an inputs defaultValue . So let's add those as well to our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found