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.

Bug Report - TypeScript error for renderRow, renderLeft/RightButton

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
bell-stevencommented, Oct 22, 2020

Please create the PR. I have virtually no experience with typescript.

0reactions
rgordon95commented, Oct 22, 2020
Read more comments on GitHub >

github_iconTop 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 >

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