1

Hold on, I've found a solution! The WrappedMap only needs to be typed as any.

I'm a beginner at TypeScript. I am currently working on "react-google-maps" The error message (Element is not assignable to type 'never') comes with the four elements: containerElement, mapElement, googleMapURL and loadingElement.

Does somebody has any idea?

import React from "react";
import {withScriptjs, withGoogleMap, GoogleMap} from "react-google-maps";



export default function GoogleMapsPage() {
    function Map() {
        return (
            <GoogleMap
                defaultZoom={10}
                defaultCenter={{lat: 48.13909, lng: 22.58030}}>
            </GoogleMap>
        )
    }

    //const WrappedMap = withScriptjs(withGoogleMap(Map));
    const WrappedMap: any = withScriptjs(withGoogleMap(Map));  //this works.


    return (
            <div style={{width: '100vw', height: '100vh'}}>

                <WrappedMap
                    containerElement={<div style={{height: `400px`}}/>}
                    mapElement={<div style={{height: `100%`}}/>}
                    googleMapURL={`https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=${process.env.REACT_APP_GOOGLE_MAPS_API_KEY}`}
                    loadingElement={<div style={{height: `100%`}}/>}>
                </WrappedMap>


            </div>
    )
}



Alligator
  • 250
  • 1
  • 7
  • 14

0 Answers0