Bug Report - TypeScript error for renderRow, renderLeft/RightButton
See original GitHub issueDescribe the bug
node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.d.ts:409:3
409 renderRow?: (data: GooglePlaceData) => React.ComponentType<{}>;
~~~~~~~~~
The expected type comes from property 'renderRow' which is declared here on type 'IntrinsicAttributes & GooglePlacesAutocompleteProps & RefAttributes<GooglePlacesAutocompleteRef>'
a similar error manifests for all three renderRow renderLeftButton renderRightButton.
src/routes/LiveUserProfile/LiveUserLocationModal/index.tsx:200:21 - error TS2322: Type '() => JSX.Element' is not assignable to type '() => ComponentType<{}>'.
Type 'Element' is not assignable to type 'ComponentType<{}>'.
Type 'Element' is not assignable to type 'FunctionComponent<{}>'.
Type 'Element' provides no match for the signature '(props: { children?: ReactNode; }, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<...>)> | null'.
200 renderLeftButton={() => {
~~~~~~~~~~~~~~~~
node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.d.ts:407:3
407 renderLeftButton?: () => React.ComponentType<{}>;
~~~~~~~~~~~~~~~~
The expected type comes from property 'renderLeftButton' which is declared here on type 'IntrinsicAttributes & GooglePlacesAutocompleteProps & RefAttributes<GooglePlacesAutocompleteRef>'
src/routes/LiveUserProfile/LiveUserLocationModal/index.tsx:208:21 - error TS2322: Type '() => JSX.Element' is not assignable to type '() => ComponentType<{}>'.
Type 'Element' is not assignable to type 'ComponentType<{}>'.
Type 'Element' is not assignable to type 'FunctionComponent<{}>'.
208 renderRightButton={() => {
~~~~~~~~~~~~~~~~~
node_modules/react-native-google-places-autocomplete/GooglePlacesAutocomplete.d.ts:408:3
408 renderRightButton?: () => React.ComponentType<{}>;
~~~~~~~~~~~~~~~~~
The expected type comes from property 'renderRightButton' which is declared here on type 'IntrinsicAttributes & GooglePlacesAutocompleteProps & RefAttributes<GooglePlacesAutocompleteRef>'
src/routes/LiveUserProfile/LiveUserLocationModal/index.tsx:224:21 - error TS2322: Type '(results: GooglePlaceData) => Element' is not assignable to type '(data: GooglePlaceData) => ComponentType<{}>'.
Type 'Element' is not assignable to type 'ComponentType<{}>'.
Type 'Element' is not assignable to type 'FunctionComponent<{}>'.
224 renderRow={(results): JSX.Element => {
~~~~~~~~~
Reproduction - (required - issue will be closed without this)
Steps to reproduce the behavior - a minimal reproducible code example, link to a snack or a repository.
Please provide a FULLY REPRODUCIBLE example.
Click to expand!
<GooglePlacesAutocomplete
renderLeftButton={() => {
return (
<SVGIcon
icon={icons.search.searchMagnifyingGlass}
style={styles.searchIcon}
/>
);
}}
renderRightButton={() => {
return (
<>
<TouchableOpacity
onPress={(): void => {
onDismissModal(false);
}}
>
<Text style={styles.cancelText}>
{locales.cancel}
</Text>
</TouchableOpacity>
</>
);
}}
renderRow={(results): JSX.Element => {
return (
<View style={styles.resultsContainer}>
<TouchableOpacity
onPress={(): void => {
setLocation(results.description);
}}
>
<View style={styles.resultsRow}>
<Text style={styles.resultsText}>
{results.description}
</Text>
<SVGIcon
icon={icons.search.caretOut}
/>
</View>
</TouchableOpacity>
</View>
);
}}
query={{
components: 'country:us',
key: 'myApiKey',
language: 'en',
types: '(cities)',
}}
/>
Please remember to remove you google API key from the code you provide here
Additional context
Obviously this appears to be a TS issue.
Looking here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts
I see this:
type ElementType<P = any> =
{
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
}[keyof JSX.IntrinsicElements] |
ComponentType<P>;
/**
* @deprecated Please use `ElementType`
*/
type ReactType<P = any> = ElementType<P>;
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
-
Library Version: 2.0.3
-
React Native Version: 0.61.5
-
TypeScript Version: 3.8.2
-
iOS
-
Android
-
Web
If you are using expo please indicate here:
- I am using expo
Add any other context about the problem here, screenshots etc
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Bug Workbench - TypeScript
The bug workbench lets you make reproductions of bugs which are trivial to verify against many different versions of TypeScript over time. A...
Read more >modern-errors-bugs - npm
This appends a bug reports URL to error messages. Example. Adding the plugin to modern-errors . import ModernError from 'modern ...
Read more >Typescript errors not showing in VSCode editor using ...
My issue is that I cannot display typescript errors in editor using eslint and @typescript-eslint (on VSCode for MacOs).
Read more >typescript & javascript React Template projects show errors ...
typescript & javascript React Template projects show errors when being created ... If we haven't resolved this issue for you, please report a...
Read more >Catching bugs in React using TypeScript - Messari
Runtime errors are pesky. Find out how we guarded against frequent offenders using TypeScript + React.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please create the PR. I have virtually no experience with typescript.
#643